Solved

Datagridview issue with CurrentRow.Index not having been established

Posted on 2008-06-10
2
210 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

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

21 Experts available now in Live!

Get 1:1 Help Now