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. Scrolled object positioning

Scrolled object positioning

Scheduled Pinned Locked Moved C#
graphicshelpquestion
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.
  • J Offline
    J Offline
    Jinwah
    wrote on last edited by
    #1

    Can anyone help as I am having a little trouble.. I have a panel with AutoScroll = True. I have added a panel to this control which is bigger than the parent, so scroll bars appear. Then I add another panel calculating the position using panelPos = PanelList.Count * APanel.Height; APanel.Location = new System.Drawing.Point(30, 38 + panelPos); When the scroll box is not scrolled adding panels puts each one directly below the next as I want. But if the parent is scrolled down then the position is wrong (the new panel is added too low down) by an offset. I thought the answer would be in the AutoScrollPosition property but I haven't been succesful in making it work. Any ideas? TIA Luke

    H 1 Reply Last reply
    0
    • J Jinwah

      Can anyone help as I am having a little trouble.. I have a panel with AutoScroll = True. I have added a panel to this control which is bigger than the parent, so scroll bars appear. Then I add another panel calculating the position using panelPos = PanelList.Count * APanel.Height; APanel.Location = new System.Drawing.Point(30, 38 + panelPos); When the scroll box is not scrolled adding panels puts each one directly below the next as I want. But if the parent is scrolled down then the position is wrong (the new panel is added too low down) by an offset. I thought the answer would be in the AutoScrollPosition property but I haven't been succesful in making it work. Any ideas? TIA Luke

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      If you look at the documentation for the AutoScrollPosition property, it states that negative values are returned for the X and Y properties of the Point returned from the property if a user has scrolled away from the starting position (0,0). Make sure you negate these values before factoring them into your new position for child panels. See DirectX 9.0 - Get Ambient with DirectSound[^] which should contain a sample like this (judging by the way the program works).

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      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