AD
Administrator
Syncfusion Team
December 19, 2005 05:25 AM UTC
Hi
To add a control to form at runtime first u need to create the control . then add to form.finally add eventhandlers to catch events.4 ex if u want to add a a button using c#
Button b=new Button();
b.Text="hai";
b.Location=new Point(100,300);
to add button to a form u need to use
Controls.Add(b);
to get events u should add a handler like this
b.Click+=new EventHandler(b_Click);
then define the eventhandler body
private void b_Click(object obj,EventArgs e){
MessageBox.Show("Button clicked");
}
u wil get a clearcut idea if u go thro the "Windows Form Designer generated code" region
>In reference to FAQ 2.32:
>"Windows Forms Controls/How can I add a control to a Window Form at runtime?"
>
>Once controls have been added, how do you reference events to them? The "click" and MouseUp" events I have manually keyed are being ignored.