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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top