C# 使单选按钮在默认情况下处于选中状态,并使文本框无法接受C语言中的输入#

C# 使单选按钮在默认情况下处于选中状态,并使文本框无法接受C语言中的输入#,c#,.net,C#,.net,我使用Visual Studio 2010用C#编写代码,有一个表单,其中有两个单选按钮和一个文本框,即: o Radio button 1 "Yes" o Radio button 2 "No" Textbox here x Radio button 1 "Yes" o Radio button 2 "No" Textbox here (grayed out "cannot input text") 我希望表单加载时已选择“是”单选按钮,即: o Radio button 1

我使用Visual Studio 2010用C#编写代码,有一个表单,其中有两个单选按钮和一个文本框,即:

o Radio button 1 "Yes"

o Radio button 2 "No"   Textbox here
x Radio button 1 "Yes"

o Radio button 2 "No"   Textbox here (grayed out "cannot input text")
我希望表单加载时已选择“是”单选按钮,即:

o Radio button 1 "Yes"

o Radio button 2 "No"   Textbox here
x Radio button 1 "Yes"

o Radio button 2 "No"   Textbox here (grayed out "cannot input text")
默认情况下,文本框不应接受输入。我希望这样,如果用户单击并选择单选按钮2,文本框现在可以接受输入

我如何做到这一点

private void rb_taxable_yes_CheckedChanged(object sender, EventArgs e)
{

}

private void rb_taxable_no_CheckedChanged(object sender, EventArgs e)
{

}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

在设计模式下的
窗体上,为
文本框
设置
启用
,为第一个
单选按钮
设置
选中

将两个单选按钮连接到一个事件处理程序:

private void radioButton_CheckedChanged(object sender, EventArgs e)
{
    textBox.Enabled = radioButton2.Checked;
}

以textbox1.enabled=false开始,并使用第二个单选按钮的onchecked事件来更改该选项。还可以将第一个单选按钮设置为具有radiobutton1.checked=true。

只需选择单选按钮1的属性即可

然后选择“选中”项为true 它将成为结果。 不需要编码