仅当列中存在特定值时,我才想删除网格中的当前行。
如何获取当前行的详细信息?
仅当列中存在特定值时,我才想删除网格中的当前行。
如何获取当前行的详细信息?
根据您的需要访问 CurrentRow 的 (DataGridViewRow) 单元格或 DataBoundItem 项。您必须将 DataBoundItem 对象转换为强类型数据行。
Dim oRow As FooDataRow = DirectCast(CurrentRow.DataBoundItem, FooDataRow)
以下代码执行您想要的操作:
// Get the context.
BindingContext context = myGrid.BindingContext;
// Get the currency manager.
BindingManagerBase manager = context [myDataset, "MyTable"];
// Get the current row view.
DataRowView rowView = (DataRowView) manager.Current;
// Assume you have a bit field and want to get its value
bool flag = (bool) rowView ["MyBitField"];
希望这可以帮助。