UserControl and Collections in Designer
-
Hello, I've wrote UserControl where one of properties is collection. Item of collection is object of type GroupClass. Code below: [Serializable] public class GroupClass { private string pGrpupName; private Control pGroupControl; [Category("Group")] [Description("Definition")] public string GroupName { get { return pGrpupName; } set { pGrpupName = value; } } [Category("Group")] [Description("Definition")] [Browsable(false)] public Control GroupControl { get { return pGroupControl; } set { pGroupControl = value; } } } And after when I add item to collection also groupbox should show on UC. I've override some methods in my Collection. It works. But it doesn't when I try to remove item in designer. Groupbox is still there and method RemoveItem doesn't works :( public class WRListClass<T> : Collection<T> { public event EventHandler<ItemInsertedArgs<T>> BeforeItemInserted; public event EventHandler<ItemRemovedArgs<T>> BeforeItemRemoved; public event EventHandler<ItemSetArgs<T>> BeforeItemSet; public event EventHandler<ItemInsertedArgs<T>> AfterItemInserted; public event EventHandler<ItemRemovedArgs<T>> AfterItemRemoved; public event EventHandler<ItemSetArgs<T>> AfterItemSet; public event EventHandler ListChanged; protected override void InsertItem(int index, T item) { EventHandler<ItemInsertedArgs<T>> beforehandler = BeforeItemInserted; EventHandler<ItemInsertedArgs<T>> afterhandler = AfterItemInserted; EventHandler handlerListChanged = ListChanged; if (beforehandler != null) { beforehandler(this, new ItemInsertedArgs<T>(index, item)); } base.InsertItem(index, item); if (afterhandler != null) { afterhandler(this, new ItemInsertedArgs<T>(index, item)); } if (handlerListChanged != null) { handlerListChanged(this, null); } } public new bool Remove(T item) { return base.Remove(item); } public new void RemoveAt(int index) {
-
Hello, I've wrote UserControl where one of properties is collection. Item of collection is object of type GroupClass. Code below: [Serializable] public class GroupClass { private string pGrpupName; private Control pGroupControl; [Category("Group")] [Description("Definition")] public string GroupName { get { return pGrpupName; } set { pGrpupName = value; } } [Category("Group")] [Description("Definition")] [Browsable(false)] public Control GroupControl { get { return pGroupControl; } set { pGroupControl = value; } } } And after when I add item to collection also groupbox should show on UC. I've override some methods in my Collection. It works. But it doesn't when I try to remove item in designer. Groupbox is still there and method RemoveItem doesn't works :( public class WRListClass<T> : Collection<T> { public event EventHandler<ItemInsertedArgs<T>> BeforeItemInserted; public event EventHandler<ItemRemovedArgs<T>> BeforeItemRemoved; public event EventHandler<ItemSetArgs<T>> BeforeItemSet; public event EventHandler<ItemInsertedArgs<T>> AfterItemInserted; public event EventHandler<ItemRemovedArgs<T>> AfterItemRemoved; public event EventHandler<ItemSetArgs<T>> AfterItemSet; public event EventHandler ListChanged; protected override void InsertItem(int index, T item) { EventHandler<ItemInsertedArgs<T>> beforehandler = BeforeItemInserted; EventHandler<ItemInsertedArgs<T>> afterhandler = AfterItemInserted; EventHandler handlerListChanged = ListChanged; if (beforehandler != null) { beforehandler(this, new ItemInsertedArgs<T>(index, item)); } base.InsertItem(index, item); if (afterhandler != null) { afterhandler(this, new ItemInsertedArgs<T>(index, item)); } if (handlerListChanged != null) { handlerListChanged(this, null); } } public new bool Remove(T item) { return base.Remove(item); } public new void RemoveAt(int index) {
I'm not going to bother reading that badly formatted code dump because: 1) because it is badly formatted 2) there is too much of it even if it were correctly formatted. Solution: 1) cut out anything that is not relevant to the problem. 2) surround the remaining code with 'pre' tags and format it properly You do not ask a question. What is it that you want to know? Read this[^], before editing your original post. Pay particular attention to items 2, 4, 5 and 7.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”