I can't for the life of me figure out how to check or uncheck a cell
programmatically. I've looked in Lutz's reflector to see how the
control is doing it and it calling an UpdateButtonState method that I
don't have access to.
This must be super simple but I'm just missing something.
Any help would be GREATLY appreciated :)
Dave Sexton - 29 Sep 2006 02:56 GMT
Hi,
If the DataGridView is data-bound just set the value in the associated property or column of your data source to "true".

Signature
Dave Sexton
>I can't for the life of me figure out how to check or uncheck a cell
> programmatically. I've looked in Lutz's reflector to see how the
[quoted text clipped - 4 lines]
>
> Any help would be GREATLY appreciated :)
Tim Van Wassenhove - 01 Oct 2006 00:26 GMT
> I can't for the life of me figure out how to check or uncheck a cell
> programmatically. I've looked in Lutz's reflector to see how the
> control is doing it and it calling an UpdateButtonState method that I
> don't have access to.
>
> This must be super simple but I'm just missing something.
public Form1()
{
InitializeComponent();
this.dataGridView1.Rows.Add();
}
private void button1_Click( object sender, EventArgs e )
{
bool value = (bool)( this.dataGridView1.Rows[0].Cells[0].Value ?? false );
this.dataGridView1.Rows[0].Cells[0].Value = !value;
}

Signature
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>