
DataGrid, don't want the last row (new record), how to remove
Hi Chris
To allow editing while not allowing the new row to appear then
you'll need to either bind to or get the DataView that the Grid uses as an
intermediary between the UI and the DataTable.
Once you have the DataView it has an AllowNew property that prevents new
rows being added from the DataGrid if you set it to false. It's also got an
AllowEdit property if you want to restrict that as well, or you could just
set the entire datagrid ReadOnly property to true.
You can create a DataView and bind that to the grid by using the following
code
DataView dv = new DataView(myTable);
or once you have bound to the grid you can get the DataView using this code
CurrencyManager cm =
(CurrencyManager)myDataGrid.BindingContext[myDataGrid.DataSource];
DataView dv = (DataView)cm.List;
Hope that helps
J.
Jasmine
www.datagridcolumnstyles.net
Custom DataGridColumnStyles for the Microsoft .Net Windows Forms DataGrid
Quote:
> I have a datagrid that is bound to a table.
> I want the data displayed and allow the user to select a record. But I
> don't want the blank last row displayed. I don't want them to be able to
> enter new data in this datagrid. This one is for selecting a record only.
> Thanks for any help