I want to get row index of datagridview
-
Hi everyone, I am working in button click event and i want to get row index of selected row. Kindly let me kknow. Thank you in advance (Riaz)
-
Hi everyone, I am working in button click event and i want to get row index of selected row. Kindly let me kknow. Thank you in advance (Riaz)
Wouldn't it be a whole lot faster to have a look at DataGridView's documentation. :sigh: It's well documented: DataGridView.SelectedRows Property[^]
The need to optimize rises from a bad design.My articles[^]
-
Hi everyone, I am working in button click event and i want to get row index of selected row. Kindly let me kknow. Thank you in advance (Riaz)
YourDataGrid.SelectedRows[0].Index First check if YourDataGrid.SelectedRows.Count > 0
-
Hi everyone, I am working in button click event and i want to get row index of selected row. Kindly let me kknow. Thank you in advance (Riaz)
This is how to get selected row from DataGridView in .NET 2.0 Make sure there’s a single cell that is currently selected Get current row index using {datagridview instance}.CurrentCell.RowIdex Get the selected row using {datagridview instance}.Rows({current row index}).Cells({zero based index}).Value Here’s the sample code : Dim crow = DataGridView1.CurrentCell.RowIndex dim txt as string Try txt = DataGridView1.Rows(crow).Cells(0).Value & ” || ” txt = txt & DataGridView1.Rows(crow).Cells(1).Value & ” || ” txt = txt & DataGridView1.Rows(crow).Cells(2).Value MessageBox.show (txt) Catch ex As Exception ‘ do nothing End Try
WaelA Senior Software Engineer http://www.linkedin.com/in/waelalwirr abu_wer@hotmail.com