I am trying to call a method on my parent form from a child form, which in turn calls a method in my custom user control. I am able to make the call if I do this...
In child form:
private void btnSaveNode_Click(object sender, EventArgs e)
{
frmMain frm = new frmMain();
frm.getNodeData(txtPartName.Text);
this.Hide();
}
In parent form:
public void getNodeData(string partNbr)
{
string strPartNbr = partNbr;
buildNode(strPartNbr);
}
public void buildNode(string partNbr)
{
drewsTreeView tv = new drewsTreeView();
tv.addNode(partNbr);
}
And finally, the method in the user control
public void addNode(string strPartNbr)
{
btnNode.Location = new Point(13, 13);
btnNode.Width = 200;
btnNode.Height = 40;
//btnNode.Text = strPartNbr;
btnNode.Text = "Testing";
this.Controls.Add(btnNode);
btnNode.Click += btnNode_Click;
}
So my problem is, the button does not get built in the addNode() method. If I call the method in the onLoad event of the main form, it builds just fine. I ran in debug mode, and I can see the method is getting called and the correct parameters are getting passed.
So why will it build the button when called from the parent, but not when called from the child?
.Show).Show(), orShowDialog()?