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

How to get value from gridview and set coresponding radio button in group box? dataGridView1.Rows[e.RowIndex].Cells[2] (how to get this value to a char variable?)the values are 'V' or 'N' present in the gridview.

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 + "";
}

Upvotes: 0

Views: 210

Answers (1)

Caius Jard
Caius Jard

Reputation: 74700

Assuming the radio button that represents V is called vRadioButton etc, something like:

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

where xxx is either the name or number of the column holding V or N

Ultimately you have to compare the in-grid value with a constant to generate a boolean abd set Checked to that bool

Upvotes: 0

Related Questions