We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Prevent Datagrid to create a default empty row

Thread ID:

Created:

Updated:

Platform:

Replies:

5184 Jun 24,2003 09:34 AM UTC Jan 23,2004 04:34 AM UTC WinForms 3
loading
Tags: FAQ
Gabriel Schwartz
Asked On June 24, 2003 09:34 AM UTC

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.

JJ
Replied On 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. > >

Gabriel Schwartz
Replied On 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. > > > > >

Stratovarius
Replied On January 23, 2004 04:34 AM UTC

Thanks JJ. That worked like a charm.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;