【问题标题】:Select radio button according to value根据值选择单选按钮
【发布时间】:2018-06-03 01:08:54
【问题描述】:

我正在尝试制作 2 个单选按钮“男”和“女”,所以当我打开新表单时,单选按钮会根据单元格值自动被选中。

这是用单元格值填充文本框的代码

frm.UGenderBox.Text = ListGrid.CurrentRow.Cells[4].Value.ToString();

【问题讨论】:

  • 您可以通过验证 frm.UGenderBox.Text 来实现。如果单选按钮以相同的形式出现
  • 我尝试过类似的方法,但如果 (ListGrid.CurrentRow.Cells[4].Value == "Male") { frm.UMaleRadioBtn.Select(); } if (ListGrid.CurrentRow.Cells[4].Value == "Female") { frm.UFemaleRadioBtn.Select(); }
  • 单选按钮在其他表单上

标签: c# datagridview radio-button


【解决方案1】:

这就是我要找的:)

if (ListGrid.CurrentRow.Cells[4].Value.ToString() == "Male")
        {
            frm.UMaleRadioBtn.Checked = true;
        }
        else
        {
            frm.UFemaleRadioBtn.Checked = true;
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多