JJ
JJ
June 29, 2003 04:41 PM UTC
After the code that sets the DataSource property for your datagrid, add the following:
//no adding of new rows thru dataview...
CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
((DataView)cm.List).AllowNew = false;
> I attached a sample solution to show my problem.
> When Form1 is created a new row is added with Customer ID 1.
> If I press ESC the row is removed.
> I want to prevent this default row creation.
> If the last line in Form1.cs is unmarked then two customers are created and no default row.
> I can't find anything from MSDN help on this.
>
>
GS
Gabriel Schwartz
July 1, 2003 07:24 AM UTC
The following line throws an exception since
casting (cm.List as DataView) returns null;
((DataView)cm.List).AllowNew = false;
> After the code that sets the DataSource property for your datagrid, add the following:
>
> //no adding of new rows thru dataview...
>
> CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
>
> ((DataView)cm.List).AllowNew = false;
>
> > I attached a sample solution to show my problem.
> > When Form1 is created a new row is added with Customer ID 1.
> > If I press ESC the row is removed.
> > I want to prevent this default row creation.
> > If the last line in Form1.cs is unmarked then two customers are created and no default row.
> > I can't find anything from MSDN help on this.
> >
> >
>
ST
Stratovarius
January 23, 2004 04:34 AM UTC
Thanks JJ. That worked like a charm.