Using DataGridViewRadioButtonColumn/Cell (http://msdn2.microsoft.com/
en-us/library/aa730882(VS.80).aspx) I want to select in all rows, 1 of
3 radiobuttons in a column of my datagridview programmatically. I am
trying:

string selectedRadioButton=1;
foreach(DataGridViewRow row in Grid.Rows)
{
//get the cell in the 11th column
DataGridViewRadioButtonCell radioButton =
(DataGridViewRadioButtonCell)(row.Cells[11]);

// Update the value of the cell (with a string)
This string should exist as a value of
// your bound datasource's DisplayMember field.
radioButton.Value = selectedRadioButton;

// Update the cell.
Grid.UpdateCellValue(11, row.Index);
}
So I expect this to select the second radio button in each cell. But
radioButton.Value=selectedRadioButton always is null after the
assignment. I have the column bound to an object with 2 fields
(ValueMember=Id and DisplayMember=Description). and the grid in
virtual mode. What do I have to do to set this radio button?

Re: DataGridViewRadioButtonColumn by DJE

DJE
Tue Feb 19 16:54:08 CST 2008

I resolved this...sorry for my confusing comments in the code. User
selects 1 of 3 radiobuttons and then the RadioButtonColumn in the grid
mirrors that selection.

Here is the code that worked:

if (radioButton0.Checked)
{
foreach (DataGridViewRow row in Grid.Rows)
{
row.Cells[11].Value =3D 0;
}
}

On Feb 11, 10:42=A0am, DJE <d...@copper.net> wrote:
> Using DataGridViewRadioButtonColumn/Cell
> (http://msdn2.microsoft.com/en-us/library/aa730882(VS.80).aspx
> ) I want to select in all rows, 1 of
> 3 radiobuttons in a column of my datagridview programmatically. I am
> trying:
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 string selectedRadioButton=3D1;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 foreach(DataGridViewRow row in Grid.Rows)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 //get the cell in the 11th column
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DataGridViewRadioButtonCell radioB=
utton =3D
> (DataGridViewRadioButtonCell)(row.Cells[11]);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Update the value of the cell (w=
ith a string)
> This string should exist as a value of
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // your bound datasource's Display=
Member field.
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 radioButton.Value =3D selectedRadi=
oButton;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Update the cell.
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Grid.UpdateCellValue(11, row.Index=
);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> So I expect this to select the second radio button in each cell. But
> radioButton.Value=3DselectedRadioButton always is null after the
> assignment. I have the column bound to an object with 2 fields
> (ValueMember=3DId and DisplayMember=3DDescription). and the grid in
> virtual mode. What do I have to do to set this radio button?