簡體   English   中英

如何在 c# 中將值設置為包含 4 個帶有 grideview cellclick 事件的單選按鈕的組框中的單個單選按鈕

[英]How to set a value to single radio button in a group box containing 4 radio buttons with grideview cellclick event in c#

如何從 gridview 中獲取值並在組框中設置相應的單選按鈕? dataGridView1.Rows[e.RowIndex].Cells[2] (如何將此值獲取到 char 變量?)gridview 中的值是“V”或“N”。

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
    dataGridView1.CurrentRow.Selected = true;
    textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value+"";         
    textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value + "";
    comboBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value + "";
}

假設代表 V 的單選按鈕稱為 vRadioButton 等,例如:

vRadioButton.Checked = "V".Equals(dataGridView1.CurrentRow.Cells[xxx].Value);
nRadioButton.Checked = "N".Equals(dataGridView1.CurrentRow.Cells[xxx].Value);

其中xxx是包含 V 或 N 的列的名稱或編號

最終,您必須將網格內值與常數進行比較,以生成 boolean abd set Checked to that bool

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM