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. WinForms, how to best pop up a user control on a form

WinForms, how to best pop up a user control on a form

Scheduled Pinned Locked Moved C#
csharpwinformstutorialquestion
4 Posts 4 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.
  • H Offline
    H Offline
    harleydk
    wrote on last edited by
    #1

    Hello, for my project I'm dealing with a table layout with a bunch of images. When I click one of these images (left-click, that's a requirement), I would like to pop up a control, basically a listbox with some choices. How should I best go about this? My - probably poor - choice so far is to display a form on top of the table layout form, that suits the purpose but seems not like the _right_ solution. Has anyone some inspiration for me, how I could pop some control up on a form surface which already has a layout to it? Thanks for the inspiration, Morten

    P J M 3 Replies Last reply
    0
    • H harleydk

      Hello, for my project I'm dealing with a table layout with a bunch of images. When I click one of these images (left-click, that's a requirement), I would like to pop up a control, basically a listbox with some choices. How should I best go about this? My - probably poor - choice so far is to display a form on top of the table layout form, that suits the purpose but seems not like the _right_ solution. Has anyone some inspiration for me, how I could pop some control up on a form surface which already has a layout to it? Thanks for the inspiration, Morten

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      harleydk wrote:

      choice so far is to display a form on top of the table layout form, that suits the purpose but seems not like the _right_ solution

      It is about the only solution, that I know of, unless you want to create some kind of table class that pops the listbox up, and then you are still having to use a form control.

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

      1 Reply Last reply
      0
      • H harleydk

        Hello, for my project I'm dealing with a table layout with a bunch of images. When I click one of these images (left-click, that's a requirement), I would like to pop up a control, basically a listbox with some choices. How should I best go about this? My - probably poor - choice so far is to display a form on top of the table layout form, that suits the purpose but seems not like the _right_ solution. Has anyone some inspiration for me, how I could pop some control up on a form surface which already has a layout to it? Thanks for the inspiration, Morten

        J Offline
        J Offline
        Jordanwb
        wrote on last edited by
        #3

        When the user clicks, get the mouse cursor (I don't remember how), set the location of the listbox to the location of the cursor, and add it to the form and not the table.

        1 Reply Last reply
        0
        • H harleydk

          Hello, for my project I'm dealing with a table layout with a bunch of images. When I click one of these images (left-click, that's a requirement), I would like to pop up a control, basically a listbox with some choices. How should I best go about this? My - probably poor - choice so far is to display a form on top of the table layout form, that suits the purpose but seems not like the _right_ solution. Has anyone some inspiration for me, how I could pop some control up on a form surface which already has a layout to it? Thanks for the inspiration, Morten

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          As Jordanwb suggested but you can have an invisible control and just move it and make it visible when required (may be better than creating and disposing of the control repeatedly). Deciding when to make it invisible after the user is finished will be the issue I would think. Mouse location is easy to trap on the click event.

          Never underestimate the power of human stupidity RAH

          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