In WinForm, get DataGrid's currently selected data (transfer)

xiaoxiao2021-03-06  20

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? Every form has a bindingContext. BindingContext is responsible for managing the data set bonded to the control. BindingManagerBase objects can be obtained by bindingContext (Me.DataGrid1.datasource), which allows synchronization of data binding controls that are bound 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 DataSet data from which the DataGrid is selected by this property, such as: DataRowView DRV = BindingContext (THISDATAGRID1.DATASOURCE) .CURRENT;

THIS.TEXTBOX1.TEXT = DRV [0] .tostring ();

Or use DataGrid.resouce [0] [0] .tostring method

转载请注明原文地址:https://www.9cbs.com/read-44307.html

New Post(0)