简体   繁体   English

如果选中了特定的单选按钮,如何更改标签的名称?

[英]How do I change the name of a label if a specific radio button is checked?

Through coding, if lets say radioButton2 is checked, how do I have the Text property for the Label label1 change to, for example, "Enter a different value"?通过编码,如果让我们说 radioButton2 被选中,我如何将 Label label1 的 Text 属性更改为例如“输入不同的值”?

private void radioButton2_CheckedChanged(object sender, EventArgs e)
    {

    }

This is very simple you should keep exploring but just for help这很简单,你应该继续探索,但只是为了帮助

private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
           if(radioButton2.Checked)
           {

              label1.Text = "Enter a different value";
           }
        }

Well, why can't you just set the Text property of label in your event handler like那么,你为什么不能在你的事件处理程序中设置标签的Text属性,比如

private void radioButton2_CheckedChanged(object sender, EventArgs e)
    {
       label1.Text = "Enter a different value";
    }

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

相关问题 如何从分组框中选中哪个单选按钮? - How do I get which radio button is checked from a groupbox? 如何更改标签和单选按钮索引 - How to change label and radio button index 如何在c#中检索单选按钮的name属性 - How do I retrieve the name property of a radio button in c# 如何更改在 c# 中选中的默认单选按钮 - How to change default radio button checked in c# 如何设置在向导控件中选中的先前选择的单选按钮? - How do I set previously selected radio button checked in wizard control? 有没有一种方法可以使用LINQ更改单选按钮列表中的“选中”单选按钮? - Is there a way to use LINQ to change the 'checked' radio button in a radio button list? 使用后如何保持单选按钮为选中状态? - How can I keep the radio button as checked after using it? 如何将网格中的单选按钮设置为“选中” - How can I set a radio button in a grid to “checked” 每当我在UWP中将选项从“是”更改为“否”时,如何从列表中替换选中的单选按钮的值? - How can i replace the value of checked radio button from a LIST whenever i change my option from yes to no vice versa in UWP 如何获取单选按钮值并清除表中选中的单选按钮 - How to get radio button value and clear checked radio button in table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM