custom editor for TreeView nodes

G

Guest

Hello you,
I need Your HELP.
I have my own TreeView Nodes Editor, in order to add 'MyTreeNode'', like
node which are ComboBox and so.
I have two classes. one inherit from 'TreeView' and the other from 'TreeNode'.
In 'MyTreeView' i override 'Nodes' (keyword- new) in order to open my custom
editor.
In public partial class MyTreeView : TreeView, I use the next statement:

[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
Editor(typeof(NodesTypeEditor), typeof(UITypeEditor)),
]
new public TreeNodeCollection Nodes
{
get { return base.Nodes; }
set
{
TreeNode[] myTreeNodeArray = new
TreeNode[((TreeNodeCollection)value).Count];
((TreeNodeCollection)value).CopyTo(myTreeNodeArray, 0);
((TreeNodeCollection)value).Clear();
this.Nodes.AddRange(myTreeNodeArray);
}
}
but the DesignerSerializationVisibility create the next code, which produce
casting error on run time:
MyCheckTreeNode myCheckTreeNode1 = ((MyCheckTreeNode)(new
TreeNode("TreeNode")));
I need it to be :
MyCheckTreeNode myCheckTreeNode1 = new MyCheckTreeNode("TreeNode");
In the editor i use TreeView and PropertyGrid. the code in 'Add CheckBox
Node' is:
treeView1.Nodes.Add(new MyCheckTreeNode("TreeNode"));
How can i fix it???

Please Help me. I need it fast.

Thanks,

Ran S'
 
G

glenhong

Hi,

You may possibly need to modify the node collection by overriding the
..Add and .AddRange to create your MyCheckTreeNode.
 
G

Guest

Dear glenhong,

it cann't be done!

in order to override 'Add' and so, i must inherit from 'TreeViewCollection',
which is not inhetitable. we can't also create a custom collection using
'CollectionBase', since the tree won't work...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top