【问题标题】:How to display values of radio button onto data grid view table如何在数据网格视图表上显示单选按钮的值
【发布时间】:2020-03-21 00:40:16
【问题描述】:

有 2 个单选按钮:一个用于约会,一个用于任务。我想知道如果选择了另一个单选按钮任务,我如何获得它的值。目前,即使我选择任务的单选按钮,它仍然会给我约会的价值。我可以使用 Or 函数吗?约会/任务只能选择一个按钮。

int n = dataGridView1.Rows.Add();
dataGridView1.Rows[n].Cells[0].Value = radioAppointment.Text;
dataGridView1.Rows[n].Cells[1].Value = textLocation.Text;
dataGridView1.Rows[n].Cells[2].Value = dateTimePicker1.Text;

【问题讨论】:

  • 单选按钮有一个Checked 属性指示它们是否被选中...
  • 你可能想看看RadioButtonList

标签: c# winforms


【解决方案1】:
    int n = dataGridView1.Rows.Add();
    string val;
    if(radioAppointment.checked==true){
    val=radioAppointment.Text;
    }
if(radioTask.checked==true){
    val=radioTask.Text;
    }
    dataGridView1.Rows[n].Cells[0].Value = val;
    dataGridView1.Rows[n].Cells[1].Value = textLocation.Text;
    dataGridView1.Rows[n].Cells[2].Value = dateTimePicker1.Text;

【讨论】:

    猜你喜欢
    • 2018-02-02
    • 2012-08-31
    • 1970-01-01
    • 1970-01-01
    • 2014-10-14
    • 2018-04-24
    • 1970-01-01
    • 2013-09-21
    • 1970-01-01
    相关资源
    最近更新 更多