Disable Delete row function in Datagrid 
Author Message
 Disable Delete row function in Datagrid

Assuming this is a Windows Forms DataGrid, and that the datasource is a
datatable, then you can set the AllowDelete property on the datatable's
defaultview.

        'get the datatable somehow.... eg.
        Dim dt as Datatable = CType(Me.DataGrid1.DataSource, DataTable);

        'set the AllowDelete property on the dataview associated with the
datatable
        dt.DefaultView.AllowDelete = False

Another way is to get at the underlying dataview using the Currencymanager.

        Dim cm as CurrencyManager =
CType(Me.BindingContext(Me.DataGrid1.DataSource, Me.DataGrid1.Datamember),
CurrencyManager)
        Dim dv as DataView = CType(cm.List, DataView)
        dv.AllowDelete = False

=====================
Clay Burch
Syncfusion, Inc.

visit www.syncfusion.com for the coolest tools


Quote:
> Hi, How can i disable the delete action when user clicked
> the row header of a datagrid and pressed Delete button?

> The datagrid's datasource is a dataset.

> I want user just can edit record in my datagrid only.

> Thx.

> p.s. I can't catch the event by keyPress or others. If row
> header has been clicked.



Tue, 17 May 2005 17:59:04 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Disabling Add Rows in a DataGrid in VB.net

2. Datagrid : How to disable rows?

3. How to delete a row in a datagrid.

4. Delete a row in a Datagrid using VB.net

5. DataGrid row delete

6. How to delete row from datagrid

7. Datagrids, DataSets and deleting Rows

8. DataGrid: how to handle deleted rows

9. Delete a row from datagrid

10. Delete Row in Datagrid

11. DELETE all rows in datagrid

12. Datagrid - Prevent Delete / New Rows

 

 
Powered by phpBB® Forum Software