全局变量
Private WithEvents DtForDataGrid1 As DataTable
下面是事件
Private Sub DtForDataGrid1_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles DtForDataGrid1.RowChanged
If e.Action = DataRowAction.Add Then ElseIf e.Action = DataRowAction.Delete Then End If
End Sub
删除datatable中的数据
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.C1TrueDBGrid1.RowCount > 0 Then
Me.DtForDataGrid1.Rows.RemoveAt(Me.C1TrueDBGrid1.Row)
End If
End Sub为什么这样做没有发生我想要的事件啊
Private WithEvents DtForDataGrid1 As DataTable
下面是事件
Private Sub DtForDataGrid1_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles DtForDataGrid1.RowChanged
If e.Action = DataRowAction.Add Then ElseIf e.Action = DataRowAction.Delete Then End If
End Sub
删除datatable中的数据
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.C1TrueDBGrid1.RowCount > 0 Then
Me.DtForDataGrid1.Rows.RemoveAt(Me.C1TrueDBGrid1.Row)
End If
End Sub为什么这样做没有发生我想要的事件啊
Me.DtForDataGrid1.Rows.RemoveAt(Me.C1TrueDBGrid1.Row) ,
再试一下
Private WithEvents DtForDataGrid1 As DataTable
下面是事件
Private Sub DtForDataGrid1_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles DtForDataGrid1.RowChanged
If e.Action = DataRowAction.Add Then ElseIf e.Action = DataRowAction.Delete Then End If
End Sub
删除datatable中的数据
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.C1TrueDBGrid1.RowCount > 0 Then
Me.DtForDataGrid1.Rows.RemoveAt(Me.C1TrueDBGrid1.Row)
End If
End Sub为什么这样做没有发生我想要的事件啊
ElseIf e.Action = DataRowAction.Delete Then其实是触发了RowChanged事件,如果判断是删除操作应该如下:
if( e.Action == DataRowAction.Commit && e.Row.RowState == DataRowState.Detached )你自己改成vb版本的。