Prevent adding/deleting rows in an editable DataGrid

  • Thread starter Thread starter Philip J. Fry
  • Start date Start date
P

Philip J. Fry

Hi All!

Does anyone know how to disable adding/deleting rows in a
DataGrid whose cells could be edited?

Many thanks,
Phil
 
Hi,

After you have performed the binding to the DataGrid you can use the
CurrencyManager to get the DataView used by the DataGrid and set the
AllowNew and AllowEdit properties of the DataView.

// Perform this after the binding has taken place!
CurrencyManager cm = (CurrencyManager)BindingContext[dataGrid1.DataSource];

DataView dv = (DataView)cm.List;

dv.AllowNew = false;
dv.AllowDelete = false;

Hope this Helps

Chris Taylor
 
Back
Top