Hi Jim,
Thank you for posting in the community!
Based on my understanding, you want to write a customized TreeView control,
and you want to add some design-time support for it. That is, you want the
TreeNodes in the TreeView to be selected and modify properties from
Property Browser.
================================================== =====
I think this is a much complex work, and need a lots work to do.
In .Net Windows Form designer, TreeNode is container in the TreeView
control, and it design-time behavior is first be managed by the TreeView
control. So to get what you want, you should first write the designer for
the TreeView control.
The TreeView control actually use an INTERNAL
"TreeViewControlDesigner"(This name is bogus) for its design-time
behaviro(Not the default ControlDesigner). Because this designer is
internal, you must write a customized designer for your TreeView.
The code below will allow you to expand and collapse your TreeView
control.(This is not allowed for ControlDesigner class's default behaviro)
[Designer(typeof(MyTreeViewDesigner))]
public class MyTreeView : System.Windows.Forms.TreeView
{
}
public class MyTreeViewDesigner: System.Windows.Forms.Design.ControlDesigner
{
protected override bool GetHitTest(Point point)
{
return true;
}
}
And also, you must provide your customized designer for the TreeNode class.
Unfortunately, TreeNode is not a *control*(Does not inherited from
System.Windows.Forms.Control), and it does not implement IComponent
interface. So you can not apply ControlDesigner(More detailed,
ComponentDesigner) on it.
So you must implement the IComponent interface for the your TreeNode, then
user root designer's to add the TreeNode to the VS.net designer.
Till now, you will see how many thing you need to do to get this done(What
I stated may be not the whole work you should do, extra work may need). I
strongly recommanded that you use other way to workaround.
I think you may use CollectionEditor for TreeView's Nodes property. And
modify the TreeNode's property in the Editor.
================================================== =========
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.