开发者

Winforms MDI and TreeView

I am currently working on a winforms application. In one of requirements I need to make sure that I can add a node to a treeView which is contained in a child form , when i click on a tabstrip button of t开发者_运维知识库he mdi parent.

if someone can please help me with this, it would be awesome and well appreciated..

Thanks and regards GJ


In your parent form, keep a refernce to the child form around. In the child form, add a public method or something that adds a node to the tree view. And when you click that tab strip button, just call that method on the child reference you have.

public Window
{
   ChildForm childForm;

   public Window()
   {
      childForm = new ChildForm();
      childForm.Show();
   }

   public OnTabStripClicked()
   {
       childForm.AddNode();
   }
}


public ChildForm
{
    public void AddNode()
    {
        treeView.Nodes.Add();
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜