Solved

Datagridview issue with CurrentRow.Index not having been established

Posted on 2008-06-10
2
217 Views
Last Modified: 2008-06-11
I have this piece of code included on a tabpage that I originally had set with .SelectionChanged, but it would error when the rowheader was clicked.  My issue is that the CurrentRow.Index is not set when I click outside an actual row.  The code below, I realize now with RowEnter,  has not initialized CurrentRow.Index.

What can I modify about this code where if a row becomes active in any certain way (clicked, coded, etc.) and also if headers are clicked that I can handle CurrentRow.Index.  Do I just need to create an error handler with some 'ignore' code.  I'm skeptical about that because of my 'PopulateParticipants' Sub where data is drawn from a dataview.

Thanks in advance!

Private Sub grdviewParticipants_RowChg(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grdviewParticipants.RowEnter
        If Activating Then Exit Sub
        Activating = True
        If dvParticipants.Count > 0 Then
            If grdviewParticipants.CurrentRow.Index >= 0 Then
                grdviewParticipants.CurrentCell = grdviewParticipants.Item(3, grdviewParticipants.CurrentRow.Index)
                glCurrentParticipantRow = grdviewParticipants.CurrentRow.Index
                glParticipant = dvParticipants(grdviewParticipants.CurrentRow.Index)("participant_id").ToString
                PopulateParticipants()
            End If
        End If
        Activating = False
    End Sub

Open in new window

0
Comment
Question by:TSFLLC
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 21758527
Did you try looking at e.RowIndex?
0
 

Author Comment

by:TSFLLC
ID: 21760129
Can't see the forest for the trees.

Got complacent.  This actually reduces the need for a grdview.MouseClick that I have on multiple gridviews in order to populate fields.  Instead of using CurrentRow.Index AT ALL.....use of e.RowIndex takes care of all the problems I had or may have in the future I think with populating fields from accessing the grid.

Thanks much again!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Close tabpage of custom control 9 33
Variable Event ? 3 27
Show/Hide ASP.NET controls with JQuery best practices 3 46
EF5: Question about Metadata Artifact Processing 4 15
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

776 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