?
Solved

Datagridview issue with CurrentRow.Index not having been established

Posted on 2008-06-10
2
Medium Priority
?
226 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
[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
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

743 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