Solved

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

Posted on 2010-09-16
7
390 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

16 Experts available now in Live!

Get 1:1 Help Now