Hide the properties of a parent class ?

Hi,
I've got a class which inherit from TreeNode. In this derived class, I provide a few properties to show in a propertygrid. But it also displays the properties of TreeNode. And I'd like to avoid that.

Is it possible And if so, how (any link to tutorial, documentation or help is welcomed ^^)


Answer this question

Hide the properties of a parent class ?

  • Ing. Miriam Escuadra

    You used PostFilterAttributes instead of PostFilterProperties.

    Tony


  • fanis

    see section 60.6 at this Winform FAQ


  • Brent K

    were you able to debug the control using two instances of the IDE


  • GAJMAN

    I don't really understand what you mean

  • joe630330

    Yes, thank you, I realized that : that's what I wrote in my previous post. And as I also wrote in my previous post, it still doesn't work with PostFilterProperties.
    I'll try to look in the msdn2 to check if the Keys of the properties are their name.

  • UncleHarpoon

    First, create a class that inherits from ComponentDesigner and override the PostFilterProperties method:

    Public Class MyTreeNodeDesigner

    Inherits ComponentDesigner

    Protected Overrides Sub PostFilterProperties(ByVal properties As IDictionary)

    MyBase.PostFilterProperties(properties)

    properties.Remove(" ") 'the name of the property you want to hide.

    'you can add as many properties as you want.

    End Sub

    End Class

    Then, add a Designer attribute to your TreeNode class.

    <Designer(GetType(MyTreeNodeDesigner))> _

    Public Class MyTreeNode

    Inherits TreeNode

    ...

    End Class

    Tony


  • Jasper Eenhoorn

    Thx for the help, Tony.
    I've tried to implement your solution, but I'm using managed C++, and am not sure if I did it correctly or not (it doesn't remove the BackColor property of treenode, given the following example)

    public ref class CTest : public ComponentDesigner
    {
    public:
    CTest(void) {};

    protected:
    virtual void PostFilterAttributes(IDictionary ^ attributes) override
    {
    ComponentDesigner::PostFilterAttributes(attributes);
    attributes->Remove("BackColor");
    }
    };

    [DesignerAttribute(CTest::typeid)]
    public ref class CNode : public TreeNode
    {
    public:
    CNode(void) {};

    property float aFloatProperty;
    }


  • MubasherAbad

    Ok, I've found a few things.
    First, quoted from the msdn :
    "you must not remove items in the PostFilterProperties method" and
    "You may also remove items in the PreFilterProperties method."

    So I also overrided the PreFilterProperties method to remove the attributes.

    But the problem comes from those lines :

    [DesignerAttribute(CTest::typeid)]
    public ref class INodeOptionsInterface : public System::Windows::Forms::TreeNode
    {
    ...
    };

    It doesn't seem to work : when I create a brekpoint in the PreFilterProperties method of CTest, it's never reached.
    And I must say that the new features of VS 2005, like [*Attribute(...)] are pretty obscure to me :/

    Any idea why the [DesignerAttribute(CTest::typeid)] doesn't work


  • rdcharm

    Ok, I made a mistake : I used PostFilterAttributes instead of PostFilterProperties
    But unfortunately, it still doesn't work.

    I really need helps on that. Can't anybody give me a hint A link to a good tutorial, or documentation

    Thx in advance.

  • LaurentLDI

    Do you mean that I must override every properties of the TreeNode class, and make them non browsable
    It's the only solution

  • miguelito928

    Give a new implementation of the propery by using the new keyword and then say [Browsable(false)]
  • Hide the properties of a parent class ?