Solved

Datagridview issue with CurrentRow.Index not having been established

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with error in Query 2 39
get combo value in class 5 24
Very Large data in MYSQL 7 95
VB.Net Determine if a mapped network drive exists 2 55
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 …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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