C# 2008 SP1。
我正在从当前在数据 GridView 中选择的行中删除一行。
我使用的是类型化数据集,我的数据 GridView 绑定(bind)到绑定(bind)源。
然而,我认为我的技术不是最好的,即使它有效。
非常感谢任何建议,
DataRow[] drDelete;
// Get the value of the PK from the currently selected row
DataRowView drv = (DataRowView)bsAddressBook.Current;
int index = Convert.ToInt16(drv[0]);
// Find the actual data row from the primary key and delete the row
drDelete = dsCATDialer.AddressBook.Select(string.Format("ID = '{0}'", index));
dsCATDialer.AddressBook.Rows.Remove(drDelete[0]);
最佳答案
您也可以使用 BindingSource 直接删除:
bsAddressBook.RemoveCurrent();
关于C# 从绑定(bind)源限定的类型化数据集中删除行的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/867349/