How to get datagrid cell value for the selected row?
Windows Forms Application
vb.net / access
I need to get the cell value of selected row of the datagrid and pass it on to another form to display info based on the cell value.
I went as far as to get the current cell value of the grid. could not get the datagridtextboxcolumn to work.
I have a getdataset routine which I am calling for various places and at each point passing a unique name for dataset to identify from where it is initiated.
So the problem is I am not providing the correct Tablestyles index.
I have the following code in Datagrid.DoubleClick event:
Dim j As Integer = DataGrid1.CurrentRowIndex()
Dim dgc As New DataGridCell()
dgc.ColumnNumber = 11
dgc.RowNumber = j
DataGrid1.CurrentCell = dgc
Dim dgtb As DataGridTextBoxColumn = DataGrid1.TableStyles(0).GridColumnStyles(11)
Dim pkey As String = dgtb.TextBox.Text
Error message at DatagridTextBoxColumn -
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and less than the size of the collection
Any help will be highly appreciated.
TIA