Inheriting from the TreeNode class



Hello

I have a written a class that inherits from the TreeNode class

I want to use the inherited TreeNode class to attach custom properties to
the nodes in a TreeView web control

I am trying to use the TreeNodePopulate event to read the custom property
when the user expands a node

The problem is that the custom node is not recognised when the event fires
after the page has been rendered

How can I access the custom node during postbacks, I get the feeling that
the custom node isn't being created, even though I've overridden the
CreateNode method, is there something else I should do? Do I need to
override other methods that persist the custom properties of the custom
treenode? Am I doing this the wrong way? Should I take an entirely different
approach?

Here is some of the code

public class CustomTreeView : TreeView
{
protected override TreeNode CreateNode()
{
return new CustomTreeNode();
}
}

public class CustomTreeNode : TreeNode
{
private int customInt;

public int CustomInt
{
get
{
return customInt;
}
set
{
customInt= value;
}
}

}


protected void customTreeView_TreeNodePopulate(object sender,
TreeNodeEventArgs e)
{
CustomTreeNode node = e.Node as CustomTreeNode;
// node == null
// i need to access node.CustomInt
...
}

Thanks

Alex


.



Relevant Pages

  • RE: Inheriting from the TreeNode class
    ... As for the creating custom TreeView with custom TreeNode class question, ... | I want to use the inherited TreeNode class to attach custom properties to ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Inheriting from the TreeNode class
    ... I want to use the inherited TreeNode class to attach custom properties to ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: userproperties do not persist in msg file
    ... Basicly it indicates that there are circumstances where the custom ... user opens a .msg file that has custom properties, ... .oft files are used to back up Outlook custom forms. ...
    (microsoft.public.outlook.program_forms)
  • Re: userproperties do not persist in msg file
    ... Custom properties can also be saved in .msg files and in .oft files. ... user opens a .msg file that has custom properties, ... .oft files are used to back up Outlook custom forms. ...
    (microsoft.public.outlook.program_forms)
  • Re: Displaying custom properties in a custom stencil
    ... I am drawing a block diagram of electrical components and I am developing a ... I want the make a generic stencil of a component that consists ... I think you want to define a set of Custom Properties. ...
    (microsoft.public.visio.general)

Loading