S
Stan
How to see if the control is a "container" control ?
Are there any other "container" controls except "GroupBox" and "Panel" ?
Thanks!
Are there any other "container" controls except "GroupBox" and "Panel" ?
Thanks!
property. You can put a button inside another button if you like. Or aMorten Wennevik said:Hi Stan,
Basically all Controls can be containers as Control has a Controls
Hi,
As you mentioned, I'v tried to get "Controls Property" from "Button" but I
can find!?
I'm not very clear about your concept.
My scenario:
1.Put Button1 on form1;
2.Put Button2 over Button1;
3.User "Button2.Parent" to find Button2's parent;
4.I got "form1" , not "Button1"!
If the same scenario but change "Button1" to "Panel1" then I'll get
"Panel1" as Button2's parent.
So if I want to make "Button1" as Button2's parent, how can I do?
Thanks for your kind response!
property. You can put a button inside another button if you like. Or aMorten Wennevik said:Hi Stan,
Basically all Controls can be containers as Control has a Controls
TextBox that has Button with another TextBox inside of it.
Morten Wennevik said:I'm not sure what you mean about cannot find the Controls property.
However, it is not listed if you just search "Button." in the MSDN "Look
For" list, you need to select the Control.
This sample should demonstrate putting a button inside another button.
Button button1 = new Button();
button1.Text = "Button 1";
button1.Size = new Size(100, 100);
form1.Controls.Add(button1);
Button button2 = new Button();
button2.Text = "Button 2";
button1.Controls.Add(button2);
button2.Click += new EventHandler(button2_Click);
...
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(((Button)sender).Parent.Text);
}
Note that if you just drag a button over another button in the Designer
window, the designer won't actually put the button inside the other button
but onto the underlying form. I suppose the designer assumes you don't
want Button2 inside Button1.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.