T
Tony Johansson
Hello!
I just made a test for fun to try to change all the MDI child so each one
had an add a Button.
I put the code below in an event handler but no Button is added the child
form was unchanged.
Can somebody explain why it's not possibly do in the way I did ?
I mean the tempChild and MdiChildren[x] is refering to the same object so
the
only thing that I can think of is that the child object is read only which
would explain
why my test didin't work.
for (int x = 0; x < this.MdiChildren.Length; x++)
{
// Create a temporary Button control to add to the child form.
Button tempButton = new Button();
// Set the location and text of the Button control.
tempButton.Location = new Point(100, 100);
tempButton.Text = "OK";
// Create a temporary instance of a child form (Form 2 in this
case).
Form tempChild = (Form)this.MdiChildren[x];
// Add the Button control to the control collection of the form.
tempChild.Controls.Add(tempButton);
}
//Tony
I just made a test for fun to try to change all the MDI child so each one
had an add a Button.
I put the code below in an event handler but no Button is added the child
form was unchanged.
Can somebody explain why it's not possibly do in the way I did ?
I mean the tempChild and MdiChildren[x] is refering to the same object so
the
only thing that I can think of is that the child object is read only which
would explain
why my test didin't work.
for (int x = 0; x < this.MdiChildren.Length; x++)
{
// Create a temporary Button control to add to the child form.
Button tempButton = new Button();
// Set the location and text of the Button control.
tempButton.Location = new Point(100, 100);
tempButton.Text = "OK";
// Create a temporary instance of a child form (Form 2 in this
case).
Form tempChild = (Form)this.MdiChildren[x];
// Add the Button control to the control collection of the form.
tempChild.Controls.Add(tempButton);
}
//Tony