Avoid a new record in a Datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've a datagrid asociated to a datatable. I must avoid the user to add new rows to the grid, but the user can edit the values that already exists, so the grid can't be readonly. I didn't found any property in the datagrid or the datatable to avoid new records, also any events. I'm confused :s
 
You can assign the DataSource of the DataGrid a DataView object that has the
AllowNew property set to False.

....
dataTable1.DefaultView.AllowNew = false;
this.dataGrid1.DataSource = dataTable1.DefaultView;

--
Tim Wilson
..Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}
Hector Geraldino said:
I've a datagrid asociated to a datatable. I must avoid the user to add new
rows to the grid, but the user can edit the values that already exists, so
the grid can't be readonly. I didn't found any property in the datagrid or
the datatable to avoid new records, also any events. I'm confused :s
 
Back
Top