DataGridView validation to underlying DataSource

P

Pieter

Hi,

I'm using a DataGridView with a DataGridViewCheckBoxColumn. When the users
checks or unchecks the checkbox, some actions have to happen in the
underlying DataSource and other objects. But the underlying DataSource gets
only the new value (True or False) on the moment the users leaves the cell
with the checkbox, and not on the moment that he checks the record...

Does anybody knows how I could get it validationg on the very same moment
when the users changes the value?

Thanks a lot in advance,

Pieter
 
K

Kevin Spencer

Does anybody knows how I could get it validationg on the very same moment
when the users changes the value?

Watch the cross-posting Pieter. It tends to make people "cross." And "cross"
people are less likely to help! ;-)

The problem here is, if the focus is still on the cell, how does the
DataGridView know that the user is done with it? Yes, with a
DataGridViewCheckBoxColumn, arguably the user has clicked on it, and isn't
likely to click it again, but on the other hand, since a
DataGridViewCheckBoxColumn almost always exposes a bit column, which cannot
be indexed, or be a foreign key, what's the hurry? If it's a text box, for
example, you definitely want to wait until the user has finished typing!

You may use the DataGridView.CurrentCellDirtyStateChanged event to do your
validation. I'm presuming that the validation has nothing to do with the
underlying DataSource, but with some other business rule. However, if it
does, you can call DataGridView.CommitEdit(DataGridViewErrorContexts.Commit)
to do any validation in the underlying DataSource.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer

Presuming that God is "only an idea" -
Ideas exist.
Therefore, God exists.
 

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