Solved

VB.Net - Check if Row Selected in DataGrid

Posted on 2014-01-31
2
8,113 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
2 Comments
 
LVL 7

Assisted Solution

by:XGIS
XGIS earned 50 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 450 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now