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. Visual Basic
  4. Custom Control Collection

Custom Control Collection

Scheduled Pinned Locked Moved Visual Basic
comdesigntoolsquestion
13 Posts 3 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.
  • T The ANZAC

    ok...i sought-of follow you, maybe i should rephrase what i'm actually trying to do. I'm basically trying to add lots of panels to one panel through a collection property. This collection property is: PanelItem is the second control and this property exists on the first control. Dim p_Collection as List(Of PanelItem) Public Property Collection() As List(Of PanelItem) Get Return p_collection End Get Set(ByVal value As List(Of PanelItem)) p_collection = value End Set End Property Now, when, in design mode, i click the ... button in the collection property of the first control it opens a collection editor, to this i can add, panelitems. Once i have done this and i close it. I then reopen this editor and find that no objects are now in it, yet when i go to add a new one, the number appended to the end automatically begins at 1 past the last one i added previously. So my questions are: Why is this happening? What methods,subs etc do i use without using a database? How do i get it to function like the treeview Node Collection Editor or similar?

    Please check out my articles: The ANZAC's articles

    T Offline
    T Offline
    Tom Deketelaere
    wrote on last edited by
    #4

    my first guess would be that you forgot to display the items already in the list. That would result in not being able to see the items but that they are there. In the load of you're second control (the collection editor) you should put something like this: if p_collection.count >0 then for each p as panelitem in p_collection 'display it next end if without more code I can't really be shure about it if you want to store this collection even after you're application has shutdown you will have to use a database or file or you can look into serialisation (not shure if its spelled correctly :doh:) I'm not familiar with the treeview node collection editor but I'll take a look at it on my break ;P

    T 1 Reply Last reply
    0
    • T Tom Deketelaere

      my first guess would be that you forgot to display the items already in the list. That would result in not being able to see the items but that they are there. In the load of you're second control (the collection editor) you should put something like this: if p_collection.count >0 then for each p as panelitem in p_collection 'display it next end if without more code I can't really be shure about it if you want to store this collection even after you're application has shutdown you will have to use a database or file or you can look into serialisation (not shure if its spelled correctly :doh:) I'm not familiar with the treeview node collection editor but I'll take a look at it on my break ;P

      T Offline
      T Offline
      The ANZAC
      wrote on last edited by
      #5

      no i'm not trying to store a collection after i've shutdown the application, i'm trying to achieve functionality similar to a treeview. Go into a new project and add a treeview to the form, then add to it's nodes property a few nodes, then close the collection editor of the treeview and reopen it, the nodes you added are available to be edited, this is what i'm trying to achieve.

      Please check out my articles: The ANZAC's articles

      T 1 Reply Last reply
      0
      • T The ANZAC

        no i'm not trying to store a collection after i've shutdown the application, i'm trying to achieve functionality similar to a treeview. Go into a new project and add a treeview to the form, then add to it's nodes property a few nodes, then close the collection editor of the treeview and reopen it, the nodes you added are available to be edited, this is what i'm trying to achieve.

        Please check out my articles: The ANZAC's articles

        T Offline
        T Offline
        Tom Deketelaere
        wrote on last edited by
        #6

        Ok I took a look at it ;P (first time I did it that way ;P I always do it in code) I would think that the way you do it should work. Can you provide me with the load of the collection editor or/and constructor. that way I can try to reproduce the error you have and search for a solution

        T 1 Reply Last reply
        0
        • T Tom Deketelaere

          Ok I took a look at it ;P (first time I did it that way ;P I always do it in code) I would think that the way you do it should work. Can you provide me with the load of the collection editor or/and constructor. that way I can try to reproduce the error you have and search for a solution

          T Offline
          T Offline
          The ANZAC
          wrote on last edited by
          #7

          well what i've already shown you is all i've done, it's not real complex, just two controls that inherit Panel and one has the property i've already shown, in this way it creates its own collecton editor without me having to do it manually, but i'm starting to think that i should be doing it manually, how would i go about that?

          Please check out my articles: The ANZAC's articles

          T 1 Reply Last reply
          0
          • T The ANZAC

            well what i've already shown you is all i've done, it's not real complex, just two controls that inherit Panel and one has the property i've already shown, in this way it creates its own collecton editor without me having to do it manually, but i'm starting to think that i should be doing it manually, how would i go about that?

            Please check out my articles: The ANZAC's articles

            T Offline
            T Offline
            Tom Deketelaere
            wrote on last edited by
            #8

            Ok I'v recreated you're problem I'll take a look at it on my break wich is in about 2hours and let you know

            T 1 Reply Last reply
            0
            • T Tom Deketelaere

              Ok I'v recreated you're problem I'll take a look at it on my break wich is in about 2hours and let you know

              T Offline
              T Offline
              The ANZAC
              wrote on last edited by
              #9

              Thanks a heap.

              Please check out my articles: The ANZAC's articles

              T 2 Replies Last reply
              0
              • T The ANZAC

                Thanks a heap.

                Please check out my articles: The ANZAC's articles

                T Offline
                T Offline
                Tom Deketelaere
                wrote on last edited by
                #10

                Just stumbled on to something. I can't keep myself from trying to solve this (don't know why ;P) Here is the problem: a panel hasn't got a collection property by default so the collection editor (wich only displays because the property is a list) doesn't know what to do with it. At first glance I don't think you will be able to achieve that what you want with a panel. Perhaps inheriting from a treeview will work better or a listview. But whitout knowing what exactly this custom control has to accomplish I don't know wich will be better. Another option is ofcourse to do everything manually but I can't help you with that (haven't done that) and it is probably going to be alot of work. You'll probably have to draw the control you'r self. If you tell me what functionality you are trying to accomplish perhaps I can help you search for a way to do that

                1 Reply Last reply
                0
                • T The ANZAC

                  Thanks a heap.

                  Please check out my articles: The ANZAC's articles

                  T Offline
                  T Offline
                  Tom Deketelaere
                  wrote on last edited by
                  #11

                  I just can't stop searching :doh: but I found a possibilaty to accomplish something like this you have to use a property that already exists in a standerd panel and the only one that exists is the controls property so in you first custom control change you're property to this:

                  Private p As List(Of mainsub)
                  Public Overloads Property controls() As List(Of mainsub)
                      Get
                          Return p
                      End Get
                      Set(ByVal value As List(Of mainsub))
                          p = value
                      End Set
                  End Property
                  

                  you can change the name of p and of mainsub but not of the property. the property must be controls if you do this the collection editor will work hope this helps -- modified at 5:24 Thursday 30th August, 2007 there still seems to be a problem when you run the prog I take another look at it on my break (really need to get back to work now;P)

                  T 1 Reply Last reply
                  0
                  • T The ANZAC

                    I am making a custom control which inherits from panel. This Control contains a collection field which will build a collection of another control (which also inherits from panel) in the form of List(of T). So far i have created my items (the second panel object) and during design time can go into the collection editor and add multiple items, yet when i close the collection ediotor and reopen it, the items in the collection have disappeared or are not visible in the collection builder anymore.

                    Please check out my articles: The ANZAC's articles

                    D Offline
                    D Offline
                    darkelv
                    wrote on last edited by
                    #12

                    The problem is that you've added items into the collection but it is not "saved" in the InitializeComponent() part of the computer generated code. It is not persisted. Consider reading this: http://www.codeproject.com/csharp/dzcollectioneditor.asp and maybe this http://www.codeproject.com/csharp/collcontrolsrichdes.asp

                    1 Reply Last reply
                    0
                    • T Tom Deketelaere

                      I just can't stop searching :doh: but I found a possibilaty to accomplish something like this you have to use a property that already exists in a standerd panel and the only one that exists is the controls property so in you first custom control change you're property to this:

                      Private p As List(Of mainsub)
                      Public Overloads Property controls() As List(Of mainsub)
                          Get
                              Return p
                          End Get
                          Set(ByVal value As List(Of mainsub))
                              p = value
                          End Set
                      End Property
                      

                      you can change the name of p and of mainsub but not of the property. the property must be controls if you do this the collection editor will work hope this helps -- modified at 5:24 Thursday 30th August, 2007 there still seems to be a problem when you run the prog I take another look at it on my break (really need to get back to work now;P)

                      T Offline
                      T Offline
                      The ANZAC
                      wrote on last edited by
                      #13

                      WOW! You've been a great help, haven't had a chance to try this stuff yet and the one below looks helpful also, i agree, it's an annoying puzzle that you hope has a simple answer and wel...it might not but thankyou heaps.

                      Please check out my articles: The ANZAC's articles

                      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