?
Solved

VB.Net - Check if Row Selected in DataGrid

Posted on 2014-01-31
2
Medium Priority
?
10,213 Views
Last Modified: 2014-01-31
Good Day Experts!

I am having a little bit of trouble with my project.  I have a DataGrid that I would like to check if a row is selected.  

I use this code to get the selected row but I cannot figure out how to check if a row is selected:

Dim CodeGrid As String = Me.dgrdAccessorial.Rows(Me.dgrdAccessorial.CurrentRow.Index).Cells("Code").Value.ToString

Can you offer some hints of help?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
[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 7

Assisted Solution

by:XGIS
XGIS earned 200 total points
ID: 39824582
Hello Jimbo,

Please check this code in relation to your implementation, including the display of the confirmation message.

' DataGridView Event 
Private Sub DataGridView1_SelectionChanged(..) 
   MsgBox("SelectionChanged: Current Row is " & DataGridView.CurrentRow.Index)
End Sub 

' First Row Button Event 
Private Sub FirstRow_Click(...)
   ' Force to first row
   DataGridView1.CurrentCell = DataGridView1.Rows(0).Cells(0)
   MsgBox("First Row Button Click: Current Row is  " & DataGridView.CurrentRow.Index) 
End Sub

Open in new window

0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1800 total points
ID: 39824596
To check whether or not a row is selected

If IsNothing(Me.dgrdAccessorial.CurrentRow) Then
   'No row selected
Else
   'Row selected
End If
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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

770 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