// ...
BindingContext[dgvDataView.DataSource, dgvDataView.DataMember];
// and casting to CurrencyManager
// ...
we create an instance of class CurrencyManager which derives from the abstract class BindingManagerBase.
By supplying
//...
currManager.Current
//...
we get the current item in a object type. The only thing that we have to do is to cast this object to the appropriate type. In our case DataViewRow. So here is a method returning currently selected row in DataGridView.
public static DataRow GetCurrentRow(DataGridView dgvDataView)
{
CurrencyManager currManager =
(CurrencyManager)dgvDataView.BindingContext[dgvDataView.DataSource, dgvDataView.DataMember];
DataRowView drView = (DataRowView)currManager.Current;
return drView.Row;
}
0 коментара:
Публикуване на коментар