2

I have a WinForm that has a DataGridView table. It is bound to a DataTable in conjunction with a SqlDataAdapter and SqlCommandBuilder. What is the best way (easy and easy to manage) of disabling Deletes but allowing Selects, Updates, Inserts?

Is there a one line property I can set on the grid? That is how I would prefer to do it.

Ksempac
  • 1,842
  • 2
  • 18
  • 23
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466

1 Answers1

2

Probably the easiest thing to do is to look over the properties on your DataGridView and change the AllowUserToDeleteRow to false.

RSolberg
  • 26,821
  • 23
  • 116
  • 160
  • How do you remove the delete command? The only way I can delete now is selecting the Row and hitting the "delete" keyboard button. – BuddyJoe Jun 02 '09 at 16:03
  • I updated the answer a bit with the specific way of handling this. – RSolberg Jun 02 '09 at 16:33
  • +1 sweet thanks. By the way, is the "delete" key on the keyboard the only method supported of deleting... or did I miss something? – BuddyJoe Jun 02 '09 at 16:43
  • I think in this example it is the only way of doing it. I tend to do more web forms vs. win forms programming and its a little different... – RSolberg Jun 02 '09 at 17:26