HighTechTalks DotNet Forums  

DataGridView, preventing CancelNew

Dotnet Framework (WinForms Controls) microsoft.public.dotnet.framework.windowsforms.controls


Discuss DataGridView, preventing CancelNew in the Dotnet Framework (WinForms Controls) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jim
 
Posts: n/a

Default DataGridView, preventing CancelNew - 12-27-2007 , 04:48 PM






Hi,

I have a DataGridView bound to a BindingList. When the user clicks on the
"new row" row at the bottom of the grid, a new row gets added with all the
right defaults, etc. The problem is that, unless they edit this row, it
disappears the moment they leave it. I would like for the new row to stay
put even if they do not edit it (the defaults are most often good and do not
need editing).

I have tried to call EndNew from AddNewCore, but that did not help.

Any help on this would be much appreciated.

Thanks,
Jim


Ps. Here is a simple test app to demonstrate:

namespace TestApp
{
public partial class Form1 : Form
{
PersonList _persons = new PersonList();
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = _persons;
}
}

public class PersonList : BindingList<Person>
{
public PersonList ()
: base ()
{
AllowNew = true;
}

protected override object AddNewCore()
{
Person person = new Person("<Type name here>");
Add(person);
base.EndNew(this.IndexOf(person));
return person;
}
}

public class Person
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}

public Person(string name)
{
_name = name;
}
}
}



Reply With Quote
  #2  
Old   
Jim
 
Posts: n/a

Default Re: DataGridView, preventing CancelNew - 12-28-2007 , 02:44 AM







The problem is solved. Kudos to Scott in the CSLA forum. See that thread
for details: http://forums.lhotka.net/forums/2003...ead.aspx#20039

Jim



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.