DataGridView checkbox column issue

M

Marco Pais

Hi there.

Hi have a datagridview with a textbox columns (prices) and a checkbox
column. I want that when a row is checked, some a value is incrmented with
the price colmun. Everything works fine, if I click chekbox cell slowly
(true-false-true-false...). However, if I click faster, it assumes always
true or false.

This is the code I'm using:

if (e.RowIndex > -1 && this.dgExtras.Columns[e.ColumnIndex] is
DataGridViewCheckBoxColumn)
{
dgExtras.EndEdit();

if (Convert.ToBoolean(dgExtras[e.ColumnIndex,
e.RowIndex].Value) == true)
extras += float.Parse(dgExtras[e.ColumnIndex - 1,
e.RowIndex].Value.ToString());
else
extras -= float.Parse(dgExtras[e.ColumnIndex - 1,
e.RowIndex].Value.ToString());
}

Any help would be apreciated. Thanks.

Regards.

Marco.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top