Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB 2008  - Select a row of a DataGridView control

Posted on 2009-07-08
3
Medium Priority
?
492 Views
Last Modified: 2012-05-07
I'm having a problem making a selection "stick" in this bound DataGridView control.

I am able to bring up the code shown below by clicking on the RowHeader of a given row.  If I click on the (say) 3rd row the RowIndex is shown at 2 (correct, so far.)  However, at that point the thing gets lost.  

The second message box shows the value of Cells(8) for the first row (RowIndex 0).  Moreover the cursor also jumps to the first row and stays there.  I will also mention that it jumps to the 3rd cell.

If I click on any other RowHeader I also get the same value for Cells(8) from the first row.  Also the cursor jumps to the first row (RowIndex 0) but in a different cell.  Who knows why?  I don't.  Perhaps you have a better solution.
Private Sub EvalItemsDataGridView_RowHeaderMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles EvalItemsDataGridView.RowHeaderMouseClick
        MsgBox(e.RowIndex)
        Me.EvalItemsDataGridView.CurrentCell = Me.EvalItemsDataGridView(e.RowIndex, 0)
        Dim i As Long = (EvalItemsDataGridView.CurrentRow.Cells(8).Value())
        MsgBox(i)
    End Sub

Open in new window

0
Comment
Question by:ljcor
[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
3 Comments
 
LVL 8

Expert Comment

by:Bob Hoffman
ID: 24808648
0
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 2000 total points
ID: 24808665
You've got the row and column indexes backwards here:

Me.EvalItemsDataGridView(e.RowIndex, 0)

The column index comes first. It should be:

Me.EvalItemsDataGridView(0, e.RowIndex)
0
 

Author Closing Comment

by:ljcor
ID: 31601281
Sorry I didn't get back to you earlier.  Had to be out for awhile. I thank both of you for your assistance, particularly Craig, who hit the right nail precisely on the head.  
Jack
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Loops Section Overview
Suggested Courses

610 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