| | |
Datagridview select row and column
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 4
Reputation:
Solved Threads: 0
Hi,I has a problem here...
I has a datagridview and now I would like to determine that whether column1 in row 1 is selected by the user.What should I write to do so?
I has a datagridview and now I would like to determine that whether column1 in row 1 is selected by the user.What should I write to do so?
VB.NET Syntax (Toggle Plain Text)
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick If (DataGridView1.Rows(1).Cells(1).Selected) Then MessageBox.Show("") End If End Sub
In the DataGridView control indices start from 0, so I've used 0 instead of 1.
You can trap CellClick event handler
If you want to check selected cell outside any event
HTH
You can trap CellClick event handler
VB.NET Syntax (Toggle Plain Text)
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick ' If e.ColumnIndex = 0 AndAlso e.RowIndex = 0 Then ' User clicked Col0 and Row0 End If End Sub
VB.NET Syntax (Toggle Plain Text)
Dim oCell As DataGridViewCell For Each oCell In DataGridView1.SelectedCells If oCell.ColumnIndex = 0 AndAlso oCell.RowIndex = 0 Then ' User has selected Col0 and Row0 End If Next
Teme64 @ Windows Developer Blog
![]() |
Similar Threads
- get the selected row in datagridview (VB.NET)
- DataGridViewComboBoxColumn how to populate in only certain rows? (VB.NET)
- Add a new Row in a datagridview which is binded to a datatable (C#)
- how to trap the values of a particular row in datagridview (C#)
- Datagridview problems in windows application (C#)
- datagridview (C#)
- populate datagridview combobox column and add rows to DGV (VB.NET)
- HOWTO: Run a Query on a Database using ODBC and return all Results into a DGV Object (C#)
Other Threads in the VB.NET Forum
- Previous Thread: retaining graphics
- Next Thread: Cannot get a VB.NET exe program to run on another computer.
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic binary bing button buttons center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist excel file-dialog firewall folder ftp google hardcopy image images insert isnumericfuntioncall listview login math memory mobile ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port print problemwithinstallation project reports" save savedialog searchbox serial soap sorting string table tcp temp text textbox timer toolbox trim update updown upload useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





