开发者

how to create dynamic controls and events?

i开发者_Go百科 created a dynamic control but i want to create events dynamically for the control for example button i created a dynamic button like.

    Button btn = new Button();       
    btn.Text = "click";       
    form1.Controls.Add(btn);


You can do it in the Init event of the page, by simply setting the btn.Clicked event to the appropriate delegate.

btn.Clicked += this.btnClickedEventHandler;


but = new Button(); but.Click += new EventHandler(this.button_Click); form1.Controls.Add(but);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜