PC Review


Reply
Thread Tools Rate Thread

DataGridView, preventing CancelNew

 
 
Jim
Guest
Posts: n/a
 
      27th Dec 2007
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
 
 
 
 
Jim
Guest
Posts: n/a
 
      28th Dec 2007

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
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refreshing Linq query to update second DataGridView when position in first DataGridView changes Arved Sandstrom Microsoft C# .NET 1 25th May 2008 05:06 AM
Preventing focus from leaving DataGridView Larry Microsoft Dot NET Framework Forms 4 27th Dec 2007 07:26 PM
Preventing access to Network ID Page (Preventing Admins from Changing Named/Removing from Domain) Erik Yunghans Windows XP Security 4 11th Apr 2006 05:03 PM
Clearing selection in DataGridView when user clicks outside the DataGridView control djyakov@gmail.com Microsoft Dot NET Framework Forms 0 16th Feb 2006 07:38 PM
DataGridView: Preventing deselection of a selected checkbox Mike Microsoft VB .NET 8 27th Jan 2006 07:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:48 PM.