On Jul 2, 4:16*am, Kim <K...@discussions.microsoft.com> wrote:
> * * * *foreach (DataGridViewRow row in this.dataGridView.Rows)
> * * * *{
>
> * * * * * * * * if (row.Cells[0].Value.ToString() == "true")
> * * * * * * * * {
> * * * * * * * * * *return true;
>
> * * * * * * * * }
> * * * *}
> return false;
>
> I try in a if senctens to scan a datagridview cell but how to test the
> checkbox cell I have look for som in books an on the inetenet but not found
> somehing.
>
> Best regard
> Kim
Verify that the cell is of type DataGridViewCheckBoxCell first...
You also might want to verify that the
DataGridViewCheckBoxCell.TrueValue is not null since it's an object
and not a boolean data type.
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (!row.IsNewRow)
{
if (row.Cells[0].GetType() ==
typeof(DataGridViewCheckBoxCell))
{
if ((bool)
(((DataGridViewCheckBoxCell)row.Cells[0]).TrueValue))
{
return true;
}
}
}
}
Cheers
Greg
|