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. Drag and drop controls into a usercontrols?

Drag and drop controls into a usercontrols?

Scheduled Pinned Locked Moved Visual Basic
csharpquestionvisual-studiotutorial
4 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.
  • F Offline
    F Offline
    Fu Manchu
    wrote on last edited by
    #1

    I have created a usercontrol in vb.net, but i want the ability to add other controls to this using the form designer? This already happens in visual studio, for example when you drop a panel on the form and then drag and drop another control, button, panel, anything into that panel in then adds it to the control. how can i add this function to my control?:doh: e.g Private Sub DragDropControl_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop 'gets the control End Sub Private Sub DragDropControl_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter 'reads the data and check weather this type of control can be dropped End Sub thanx

    R 1 Reply Last reply
    0
    • F Fu Manchu

      I have created a usercontrol in vb.net, but i want the ability to add other controls to this using the form designer? This already happens in visual studio, for example when you drop a panel on the form and then drag and drop another control, button, panel, anything into that panel in then adds it to the control. how can i add this function to my control?:doh: e.g Private Sub DragDropControl_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop 'gets the control End Sub Private Sub DragDropControl_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter 'reads the data and check weather this type of control can be dropped End Sub thanx

      R Offline
      R Offline
      Roy Heil
      wrote on last edited by
      #2

      So, you want to drag a control from somewhere on your form, onto your usercontrol, at design time? Do you just want it to be visible there, or do you want it to be part of the control? Normally, the drag an drop features for controls handle data from one control to another. What you want to do can probably be done, but it may take some work. Roy.

      F 1 Reply Last reply
      0
      • R Roy Heil

        So, you want to drag a control from somewhere on your form, onto your usercontrol, at design time? Do you just want it to be visible there, or do you want it to be part of the control? Normally, the drag an drop features for controls handle data from one control to another. What you want to do can probably be done, but it may take some work. Roy.

        F Offline
        F Offline
        Fu Manchu
        wrote on last edited by
        #3

        Basically my usercontrol is like a toolbar control that you would move other controls onto, but like you say Roy yes the controls added would have to then become attached or added to the main base control.

        R 1 Reply Last reply
        0
        • F Fu Manchu

          Basically my usercontrol is like a toolbar control that you would move other controls onto, but like you say Roy yes the controls added would have to then become attached or added to the main base control.

          R Offline
          R Offline
          Roy Heil
          wrote on last edited by
          #4

          OK. What you will need to do is, as the control is dropped on your user control, identify what type of control it is. I assume that you want this control to be persistant (i.e. still there when you restart your app later). If so, you need to store a list of controls to be populated on your user control. You could store the list in an XML file, or in the registry. Finally, you need to dynamically create the controls; both at startup, and when a new control is added. Remember that you are not actually dropping a control on your usercontrol, you are identifying the type of control. Sorry is this is kind of vague. I have not actually done this. But this is how I would try it. Hope this helps. Roy.

          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