AllowAddNew datagrid property in .NET

  • Thread starter Thread starter Li Pang
  • Start date Start date
L

Li Pang

Hi,

Is anyone knows the equivalence of VB6 datagrid
property "AllowAddNew" in VB.NET?

Thanks

Li
 
Hi,

There is not an allowaddnew property in the datagrid. The closest
thing is readonly. That allows you to edit or add new cells.

Ken
 
Li,
As Ken stated, the VB.NET DataGrid itself does not have an AllowNew
property.

However the DataView object that the DataGrid ultimately gets bound to does
support an AllowNew property.

When you bind a DataGrid to a Dataset & table name (or to a DataTable) the
DataGrid uses the DataTable.DefaultView property to actually bind to.

Instead of binding to a DataSet & table name I would recommend binding to a
DataView. Associate this DataView with your DataTable from your DataSet,
then set the AllowNew property on this DataView to false. Alternatively you
may be able to change the DataView returned from DataTable.DefaultView, but
remember to change it back when you want to allow adding records...

DataView is in the System.Data namespace along with DataSet & DataTable.

Hope this helps
Jay
 
Back
Top