Solved

How do I monitor when a datagrid row is changed?  VB 2005 DATAGRID

Posted on 2010-09-16
7
392 Views
Last Modified: 2012-06-21
I have a datagrid bound to a data table with 5 fields.  Two of the fields cannot be null.

All I want to do is find an event that is raised ONLY after the user leaves that row either by clicking on the previous row, next row, new row, whatever.  The reason for this is that I only want to call my dataadapter.update method once after the user leaves the row.  This gives the operator a chance to fill all of the cells in the row before my code attempts to update the database.

I'm finding plenty of events that fire after a column is entered, changed, whatever but nothing that will fire only after the row is exited.  I've got to be overlooking something...

Thanks in advance for your help.
0
Comment
Question by:LiebertUser
  • 3
  • 2
  • 2
7 Comments
 
LVL 12

Expert Comment

by:Paul_Harris_Fusion
ID: 33692111
The event is SelectionChanged
0
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33692190
If you use DataGridView, you can try event RowLeave.
0
 

Author Comment

by:LiebertUser
ID: 33692294
You wouldn't know of any clever way to pull this off with a datagrid would you?
I'm a VB6 programmer who inherited this program to support so I still struggle with this .net environment a bit.
The original programmer built this form with a datagrid (not datagridview).  Embedded within it are 3rd party custom cell objects so I was hoping that I could just implement my changes quickly with the existing datagrid.  My .net grid experience has only been with this datagrid I inherited.
I'll try chucking the datagrid in the garbage and replacing it with a datagridview...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Assisted Solution

by:Paul_Harris_Fusion
Paul_Harris_Fusion earned 250 total points
ID: 33692496
Could you use the CurrentCellChanged event to catch when the user moves to a different cell and within your handler,  check the row of the new current cell against the row of the old current cell (which you saved earlier....)

0
 
LVL 17

Accepted Solution

by:
Zhaolai earned 250 total points
ID: 33692667
Like Paul_Harris_Fusion said, you can implement CurrentCellChanged event by adding the following code in the event:

        Static iRowIndex As Integer

        If iRowIndex <> DataGrid.CurrentRowIndex Then

            'on a different row now

            'update your table here



            iRowIndex = DataGrid.CurrentRowIndex

        End If

Open in new window

0
 

Author Closing Comment

by:LiebertUser
ID: 33695190
Thanks Paul_Harris_Fusion and Zhaolai.  That worked perfectly.  Hope you don't mind but I'll split the points.  Paul answered and Zhaolai coded it.
0
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33695230
It's always a good idea to split points to the people who provided any help. :=)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now