Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. UserControl and Collections in Designer

UserControl and Collections in Designer

Scheduled Pinned Locked Moved C#
database
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cinias
    wrote on last edited by
    #1

    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) {

    H 1 Reply Last reply
    0
    • C cinias

      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) {

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      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.”

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups