Avoid a new record in a Datagrid

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
 
T

Tim Wilson

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
 

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

Top