简体   繁体   English

有没有办法检查表单中是否单击了任何单选按钮?

[英]Is there a way to check if any radio button has been clicked in a form?

I'm creating a form and I want the text of a button to change depending on if any radio button in the whole form has been clicked on, additionally some radio buttons are in group boxes so do not affect other radio buttons.我正在创建一个表单,我希望按钮的文本根据是否单击了整个表单中的任何单选按钮来更改,另外一些单选按钮位于组框中,因此不会影响其他单选按钮。 The only way I can think of to do this is to input code into every method that is called for when each radio button is clicked.我能想到的唯一方法是将代码输入到单击每个单选按钮时调用的每个方法中。 Is there any other way of doing it?还有其他方法吗?

you can create one method for click event for one radioButton only and make all radioButtons share this click event and i will suppose that you will make Button text like radioButton text which you clicked and inside this method write this line...您可以仅为一个单选按钮创建一种单击事件的方法,并使所有单选按钮共享此单击事件,我假设您将制作按钮文本,如您单击的单选按钮文本,并在此方法中写入此行...

private void radioButton1_Click(object sender,EventArgs e) {
    button1.Text = (RadioButton(sender)).Text;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM