Adding a Click event handler programmatically to a radio button

风格不统一 提交于 2021-02-07 09:21:55

问题


I know for a button, I can do this:

this.button1.Click += new System.EventHandler(this.button_Click);

But how can I do it for a radio button?


回答1:


How about:

 radioButton1.Click += new RoutedEventHandler(radioButton1_Click);


 private void radioButton1_Click(object sender, RoutedEventArgs e)
 {

 }



回答2:


this.button1.Checked += ...

this.button1.Unchecked += ...


来源:https://stackoverflow.com/questions/4780193/adding-a-click-event-handler-programmatically-to-a-radio-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!