【发布时间】:2013-07-23 23:40:21
【问题描述】:
我有一个从数据库中获取性别值的文本框。根据 textchanged 事件,单选按钮做出相应的响应。
private void txtInvisibleGender_TextChanged(object sender, EventArgs e)
{
if (txtInvisibleGender.Text == "Female")
rbFemale.Checked = true;
else
rbMale.Checked = true;
}
问题是当文本框中的数据是女性时,为什么要选中男性单选按钮?它不会根据文本框中的数据进行检查。我该如何完成这项工作?
【问题讨论】:
-
向我们展示这个txtInvisibleGender.Text的文本
-
txtInvisibleGender.Text = read["Gender"].ToString();
-
试试我的答案。并始终使用 equals 进行字符串比较
标签: c# winforms radio-button