gpt4 book ai didi

c# - Datagridview 如何跳过删除的空白行?

转载 作者:太空宇宙 更新时间:2023-11-03 15:40:05 28 4
gpt4 key购买 nike

datagridview 如何跳过删除的空白行?这是以下错误:

Deleted row information cannot be accessed through the row

这是我的代码:http://pasted.co/bcb3fb31

最佳答案

您必须实现如下所示的 SQL DataTable 事件处理程序:

YourDataTable.RowDeleted += new DataRowChangeEventHandler(dataTable_RowChanged);

private void dataTable_RowChanged(object sender, DataRowChangeEventArgs e)
{
DataRow _dr = e.Row as DataRow;
try
{
if (e.Row.RowState == DataRowState.Deleted)
{
// YOUR CODE
}
if (e.Row.RowState == DataRowState.Added) { //OPTIONAL }
if (e.Row.RowState == DataRowState.Modified) { //OPTIONAL}
}
catch (Exception ex) { }
finally { _dr = null; }
}

希望这对您有所帮助。最好的问候,

关于c# - Datagridview 如何跳过删除的空白行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30547633/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com