Hi I开发者_JAVA技巧 write a component and need to when one control add to form i detect this event and add this control to my component list , is this possible ? (Design time)
excuse me for my poor english tnx
Do you mean System.Windows.Forms.Control.ControlAdded event?
EDIT: The event is raised in DesignTime either.
I created Form2
class:
public partial class Form2 : Form {
public Form2() {
InitializeComponent();
this.ControlAdded += new ControlEventHandler(Form2_ControlAdded);
}
void Form2_ControlAdded(object sender, ControlEventArgs e) {
this.Text += " " + e.Control.Name;
}
}
And then I created Form3
class derived from Form2
class.
public partial class Form3 : Form2 {
public Form3() {
InitializeComponent();
}
}
After that I recompiled solution, opened designer of Form3
class, added new Button
from ToolBox and the Text
property of form was changed from "Form3" to "Form3 button1".
精彩评论