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. .NET (Core and Framework)
  4. UserControls as Containers

UserControls as Containers

Scheduled Pinned Locked Moved .NET (Core and Framework)
questionvisual-studiodockerhelptutorial
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.
  • G Offline
    G Offline
    Gary Ranson
    wrote on last edited by
    #1

    Hi, Can you help ? I don't know how to phrase my question so I have written it out in serveral different ways. They all make sense to me but that is because I know what I want! And the question ? ....... If I inherit from a System.Windows.Forms.ContainerControl I can use the inherited control as a container type control within the IDE, and drag-drop toolbox items into it. However if I inherit from a UserControl, the the ability to drag-drop controls into it seems to be disabled. What I am attempting to do is create a container control that can be drag-dropped onto a form and be used as any normal container control (eg. Panel). To do this I can inherit from the ContainerControl and all is well. As an extension to this I would also like to be able to inherit directly from the control and use it as a designer base. If I inherit from a UserControl, then I can use the default usercontrol designer, but I cannot then use the created control on a Form, and drag-drop toolbox items into it. Is there anyway of creating a container control, which is based on a UserControl, and use the created control within the IDE in the sameway as all the built-in container controls. Gary Ranson.

    J 1 Reply Last reply
    0
    • G Gary Ranson

      Hi, Can you help ? I don't know how to phrase my question so I have written it out in serveral different ways. They all make sense to me but that is because I know what I want! And the question ? ....... If I inherit from a System.Windows.Forms.ContainerControl I can use the inherited control as a container type control within the IDE, and drag-drop toolbox items into it. However if I inherit from a UserControl, the the ability to drag-drop controls into it seems to be disabled. What I am attempting to do is create a container control that can be drag-dropped onto a form and be used as any normal container control (eg. Panel). To do this I can inherit from the ContainerControl and all is well. As an extension to this I would also like to be able to inherit directly from the control and use it as a designer base. If I inherit from a UserControl, then I can use the default usercontrol designer, but I cannot then use the created control on a Form, and drag-drop toolbox items into it. Is there anyway of creating a container control, which is based on a UserControl, and use the created control within the IDE in the sameway as all the built-in container controls. Gary Ranson.

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      You can get a start by adding a reference to System.Design.dll and adding the following attribute to your UserControl [Designer(typeof(System.Windows.Forms.Design.ParentControlDesigner))] You may want to put some code into the Paint event so that you draw a border around the control if DesignMode is true; otherwise the control will blend into the form with the default values. James "And we are all men; apart from the females." - Colin Davies

      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