By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,028 Members | 1,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,028 IT Pros & Developers. It's quick & easy.

Cancelling Mousedown Event in Datagrid

P: n/a
I have a read only datagrid that is designed to coordinate itself with
textboxes. When the user clicks on a row in the datagrid, detailed
data for that row is displayed for editing in the textboxes. The
datagrid and textboxes are populated from the same underlying SQL
Server table but using different strongly typed data adapters and
datasets for display and editing. So I coordinate syncronization of
the two sets of data using code. I use the datagrid mousedown event
with hitTest to capture what row is clicked in the datagrid and then
find that row in the details dataset. This all works just fine.
However, before I allow the user to switch rows, I validate and save
the detailed information in the textboxes. My problem is that when the
detail in the textboxes fail my validation tests I want the data grid
to remain positioned on the invalid row until the details pass
validation and are saved. As it is now, the datagrid moves to the row
that was clicked and will not stay on the invalid row. In the meantime
my detail textboxes stay positioned on the invalid row until all data
passes validation. So, the datagrid selected row is now out of sync
with the details being displayed in the textboxes. I have tried to
reposition the datagrid using CurrentCellChanged event, the mouseUp
event, DataGrid.Unselect, DataGrid.IsSelected, and even in the
mousedown event after I issue the save/validate. It seems no matter
what event I use to try to cancel/revert the navigation in the
datagrid, the application wants to finish the mouse down action and
move the datagrid to the row that was clicked on. Then it seems there
are no other events firing that allow me to reposition the datagrid
row back to the original invalid row so that the datagrid and detail
texboxes stay in sync. Can anybody suggest an event for me to key in
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Hi Greg,

I suspect you need to Inherit a DataGrid and override its
I can't tell you exactly how but I see it used quite frequently to filter

Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.