We know that when using DataGrid, we often use DataTable, DataSet, DataView as its data source, then when filling, can we take DataSet's DataSet's data data?
Before telling the answer, first, you can't get it, you can't use CType (Me.DataGrid1.DataSource, DataTable). Rows (Me.DataGrid1.currenTrowIndex), because if the data in the DataGrid is sorted or reduced, CurrenTrowIndex cannot be There is an error.
Each
Form has one
BindingContext.
BindingContext is responsible for managing the data set bonded to the control.
Can be obtained by bindingcontext (me.datagrid1.datasource)
BindingManagerBase object, which allows for synchronization of data binding controls that bind to the same data source on the Windows Form.
BindingManagerBase contains the status of the current location and record number of the data source, respectively.
BindingManagerBase has a property that is Current, which represents the current record. So you can get the data of the DataSet corresponding to the DataGrid, such as:
DIM DRV AS DATAROWVIEW = BindingContext (me.datagrid1.datasource) .current
Messagebox.show DRV (0)