Solved

Datagridview issue with CurrentRow.Index not having been established

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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