Solved

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

Posted on 2010-09-16
7
399 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
Technology Partners: 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!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

680 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