470,833 Members | 1,451 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

Cancelling Mousedown Event in Datagrid

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
1 2572
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.

Similar topics

2 posts views Thread by JJ | last post: by
2 posts views Thread by Randy | last post: by
2 posts views Thread by Boaz Ben-Porat | last post: by
7 posts views Thread by Scott Mackay | last post: by
4 posts views Thread by rsmith | last post: by
1 post views Thread by Alan | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.