![](/img/trans.png)
[英]C# Radio buttons: how can I assign two values to a single radio button. One text value for front-end user, and the other ID value for the program
[英]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.