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. custom group controls

custom group controls

Scheduled Pinned Locked Moved C#
questiondesignhelp
3 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.
  • N Offline
    N Offline
    NoCake
    wrote on last edited by
    #1

    Heya, I'm having problems creating a custom group control (which I'll call XPanel for now). I'd like XPanel to be a user control consisting of several sub-panels, that the XPanel user can add their own child controls to. I have two problems with this: 1) If I add an event handler to the XPanel.ControlAdded event that transfers the added control to one of the sub-panels, I get an error in a message box at design time: "'child' is not a child control of this parent". This doesn't happen if I create and add the control at run-time. 2) How do I allow the sub-panels to be selectable at design time? Will I have to write my own design-time painting and interaction code? At the moment, the XPanel appears as a big indivisible unit when I add it to a form. Thanks in advance! Andy

    B 1 Reply Last reply
    0
    • N NoCake

      Heya, I'm having problems creating a custom group control (which I'll call XPanel for now). I'd like XPanel to be a user control consisting of several sub-panels, that the XPanel user can add their own child controls to. I have two problems with this: 1) If I add an event handler to the XPanel.ControlAdded event that transfers the added control to one of the sub-panels, I get an error in a message box at design time: "'child' is not a child control of this parent". This doesn't happen if I create and add the control at run-time. 2) How do I allow the sub-panels to be selectable at design time? Will I have to write my own design-time painting and interaction code? At the moment, the XPanel appears as a big indivisible unit when I add it to a form. Thanks in advance! Andy

      B Offline
      B Offline
      bobsugar222
      wrote on last edited by
      #2

      I've just tried and I can add sub-controls to 'XPanel' in the VS-designer without issue if I inherit XPanel from Panel instead of UserControl. No ControlAdded event handling required.

      N 1 Reply Last reply
      0
      • B bobsugar222

        I've just tried and I can add sub-controls to 'XPanel' in the VS-designer without issue if I inherit XPanel from Panel instead of UserControl. No ControlAdded event handling required.

        N Offline
        N Offline
        NoCake
        wrote on last edited by
        #3

        Hi Bob, Thanks! I think I wasn't clear about it, though - I have no problem inheriting XPanel from Panel and adding child controls, but that's not quite what I want. XPanel has N child panels S1..SN, that could look like this: +-XPanel------------+ |...................| |.+-S1--+...........| |.|.....|...........| |.+-----+..+-S2--+..| |..........|.....|..| |..........+-----+..| |...................| +-------------------+ If the user of XPanel adds an instance to a form, I would like her to be able to add controls to XPanel.S1 or XPanel.S2, instead of to XPanel directly. Which is why I wanted to handle ControlAdded, so I could pass controls added to XPanel on to XPanel.S1 or XPanel.S2. Thanks again, Andy -- modified at 10:35 Monday 29th January, 2007 (got inheritance order wrong :)

        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