How To Prevent Datagrid Row Deletion
Visual Basic
1
Posts
1
Posters
0
Views
1
Watching
-
I am using a windows form datagrid and a datatable is used as the datasource.I want to prevent deletion of the first row.I tried with datatable's rowdeleting event.But i was not able to reject the changes.Can any one help.I'm pasting the code that i tried Private Sub DataTable_RowDeleting(ByVal sender As System.Object, ByVal e As System.Data.DataRowChangeEventArgs) If e.Action = DataRowAction.Delete Then If dgGrid.CurrentCell.RowNumber = 0 Then e.Row.RejectChanges() CType(sender, DataTable).AcceptChanges() End If Else e.Row.AcceptChanges() End If End Sub Anup