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

x
?
Solved

VB.Net - Check if Row Selected in DataGrid

Posted on 2014-01-31
2
Medium Priority
?
10,635 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
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