Solved

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

Posted on 2010-09-16
7
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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