我的项目中有MyForm.cs, MyForm.Designer.cs
文件,MyForm.Designer.cs
我这样做了:
private System.Windows.Forms.TreeView myTreeView;
this.myTreeView = new System.Windows.Forms.TreeView();
.........
this.myTreeView.AfterSelect +=
new TreeViewEventHandler(this.myTreeView_AfterSelect);
像MyForm.cs
这样:
private void myTreeView_AfterSelect(object sender, TreeViewEventArgs e)
{
//........;
}
我也有CostumeTreeView
其他文件(CostumeTreeView.cs
和CostumeTreeView.Designer.cs
)的课程,
CostumeTreeView.Designer.cs
我确实喜欢这样:
private System.Windows.Forms.TreeView myCostumeTreeView
this.myCostumeTreeView = new System.Windows.Forms.TreeView();
...........
this.myCostumeTreeView.DrawMode =
System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll;
this.myCostumeTreeView.DrawNode +=
new DrawTreeNodeEventHandler(this.myCostumeTreeView_DrawNode);
在CostumeTreeView.cs
:
private void myCostumeTreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
........
//Here is the problem, myTreeView isn't seen here
e.Node.Tag = myTreeView.SelectedNode.Text;
}
我需要在myTreeView
选择节点时,myCostumeTreeView
使用后选择功能更改所有标签(所有方法都在一个命名空间中)