Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling the Delete functionality of the Datagrid

Status
Not open for further replies.

DBNECWaters

Programmer
Mar 9, 2005
6
0
0
US
I was wondering if it was possible to disable the delete action associated with the Datagrid (System.Windows.Forms.DataGrid). I want the data grid to be able to be edited I just don't want the user to be able to delete a row when it is selected, or even preventing it from being selected in the first place.

Thanks!
 
You can prevent deletes by getting a reference to the DataView for the grid and setting the AllowDelete property to false. Put the following code after the grid has been populated.
Code:
Dim cm As CurrencyManager = CType(DataGrid1.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember), CurrencyManager)

CType(cm.List, DataView).AllowDelete = False
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top