Solved

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

Posted on 2010-09-16
7
396 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

813 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

15 Experts available now in Live!

Get 1:1 Help Now