开发者

Winforms MDI and TreeView

开发者 https://www.devze.com 2023-03-06 14:13 出处:网络
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

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

精彩评论

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

关注公众号