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. Move objects in panel

Move objects in panel

Scheduled Pinned Locked Moved Visual Basic
questioncsharpdata-structures
5 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.
  • B Offline
    B Offline
    bamnet
    wrote on last edited by
    #1

    {vb .net 2003} I'm working on creating a few side panels for my application that will slide in and slide out as needed. I have one docked on the left side, so it will resize with the window and still look the way I want it to. To "slide" it, I'm using a timer that decreases the width of it, making it look like its sliding out. I want to move all the controls in it (labels and picture boxes) to follow the sliding motion but I can't change the width without screwing up how the text looks, so I decrease the left value of the label as I decrease the width of the panel. My question is this: Is there a way to adjust the left property of all control in a panel at the same time without having to hardcode each individual label? I thought about doing a control array but then I would need seperate arrays for each type of element. Any idea? Thanks for your time, BAM

    D B 2 Replies Last reply
    0
    • B bamnet

      {vb .net 2003} I'm working on creating a few side panels for my application that will slide in and slide out as needed. I have one docked on the left side, so it will resize with the window and still look the way I want it to. To "slide" it, I'm using a timer that decreases the width of it, making it look like its sliding out. I want to move all the controls in it (labels and picture boxes) to follow the sliding motion but I can't change the width without screwing up how the text looks, so I decrease the left value of the label as I decrease the width of the panel. My question is this: Is there a way to adjust the left property of all control in a panel at the same time without having to hardcode each individual label? I thought about doing a control array but then I would need seperate arrays for each type of element. Any idea? Thanks for your time, BAM

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Instead of resizing the panel to make appear to slide, try changing it's location so that the panel slides off the left side of the form. The X portion of the Location can be in negative numbers and it should still work.

      Dave Kreskowiak Microsoft MVP - Visual Basic

      B 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Instead of resizing the panel to make appear to slide, try changing it's location so that the panel slides off the left side of the form. The X portion of the Location can be in negative numbers and it should still work.

        Dave Kreskowiak Microsoft MVP - Visual Basic

        B Offline
        B Offline
        bamnet
        wrote on last edited by
        #3

        I tried changing panel1.location.x to a negative number and the panel won't budge. I think its because the panel is docked to that left side.

        D 1 Reply Last reply
        0
        • B bamnet

          I tried changing panel1.location.x to a negative number and the panel won't budge. I think its because the panel is docked to that left side.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          That's why. You have to turn the dock off in order for it to work. Just make you Anchor the Top and Bottom portions of the Panel to the form after you get it's dimensions set properly.

          Dave Kreskowiak Microsoft MVP - Visual Basic

          1 Reply Last reply
          0
          • B bamnet

            {vb .net 2003} I'm working on creating a few side panels for my application that will slide in and slide out as needed. I have one docked on the left side, so it will resize with the window and still look the way I want it to. To "slide" it, I'm using a timer that decreases the width of it, making it look like its sliding out. I want to move all the controls in it (labels and picture boxes) to follow the sliding motion but I can't change the width without screwing up how the text looks, so I decrease the left value of the label as I decrease the width of the panel. My question is this: Is there a way to adjust the left property of all control in a panel at the same time without having to hardcode each individual label? I thought about doing a control array but then I would need seperate arrays for each type of element. Any idea? Thanks for your time, BAM

            B Offline
            B Offline
            bamnet
            wrote on last edited by
            #5

            I figured out what works best for me. Turning off the docking features completely messed up everything that was going on with resizing the window, so I used the approach of decreasing width. To deal with the items inside, I used the Controls array that contains every object in a panel to adjust the width. Heres the code: For intIndex = 0 to Me. Controls(panel).Controls.Count - 1 Me.Controls(panel).Controls(intIndex).left = Me.Controls(panel).Controls(intIndex).left - operation next intIndex With this, operation is set to positive or negative 1, depending on if i'd like to show or hide the item. panel is set to the number that corresponds to the panel. I really don't know how to determine besides trial and error (or trial and messagebox). Thanks again, BAM

            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