Pergunta

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 the mdi parent.

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

Thanks and regards GJ

Foi útil?

Solução

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();
    }
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top