473,394 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
on.
Nov 16 '05 #1
1 2874
Hi Greg,

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

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JJ | last post by:
Hi All, I need to create a MouseDown event for a picture box . Am I doing the following right? pictureBox.MouseDown += new System.WinForms.MouseEventHandler(pictureBox_MouseDown) Then
0
by: Baseman | last post by:
I am trying to find out how to cancel all TreeView events if an exception occurs during any one of the following... MouseDown BeforeSelect AfterSelect DragDrop DragEnter DragOver...
2
by: Randy | last post by:
Hello all, I'm trying to capture the column and row of the datagrid cell clicked. I'm have problems figuring this out. I think it is simple but eludes me. I have a datagrid and a MouseDown...
2
by: Boaz Ben-Porat | last post by:
Is there any way to determine if the CTRL key is pressed from a MouseDown event on a DataGrid ? TIA Boaz ben-Porat DataPharm a/s Denmark
7
by: Scott Mackay | last post by:
Hi, I'm using visual studio dotnet 2002 programming in vb can anyone tell me how I can handle the mousedown event for pictureboxes I create dynamically at runtime? I've tried setting the...
4
by: rsmith | last post by:
How can I capture the MouseDown event on a Label ? I entered thr following code and got a " cannot handle Event 'MouseDown' because they do not have the same signature." Private Sub...
1
by: Alan | last post by:
i have a form with a label on it Private Sub Label1_mousedown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown ' do stuff End Sub ...
4
by: genojoe | last post by:
I have a combobox control on the form. When the user makes a change, I want to validate a condition before permitting the change. If the condition is not met, I want to return the ComboBox text...
1
by: Joseph Geretz | last post by:
I'm noticing that when my DataGrid has focus, it handles the Enter key by advancing to the next row in the grid. This neutralizes Forms's current defined AcceptButton. My primary question: is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.