Hi,
Sorry. I am not able to reproduce this issue base on your code. I add an item and cancel, then open the edit form, the item doesn’t show. The following is my test.
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
base.BorderStyle = BorderStyle.FixedSingle;
}
private ColumnCollection _TestSimpleItems = new ColumnCollection();
[Category("Collections")]
public ColumnCollection TestSimpleItems
{
get { return _TestSimpleItems; }
}
}
/////////////////////////
public class TestGrid
{
public DataGridView Grid = new DataGridView();
}
public class ColumnCollection : Collection<TestGrid>
{
// Inside this i have overrided the following methods
public DataGridView Grid = new DataGridView();
protected override void InsertItem(int index, TestGrid item)
{
base.InsertItem(index, item);
item.Grid = this.Grid;
//OnItemAdded(new ColumnsEventArgs(item));
}
protected override void RemoveItem(int index)
{
//ColumnBase col = this[index];
base.RemoveItem(index);
//OnItemsRemoved(new ColumnsEventArgs(col));
}
protected override void ClearItems()
{
base.ClearItems();
//OnItemsCleared(new ColumnsEventArgs(null));
}
}
Besides, it seems you have created a new CollectionEditor. I am not very sure if there are something causing this issue.
The following is an example about working with CollectionEditor. Hope this helps.
How to Edit and Persist Collections with CollectionEditor
http://www.codeproject.com/KB/cs/dzcollectioneditor.aspx
Best regards,
Ling Wang
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.