简体   繁体   中英

How to get a control's location inside an autoscrollable panel? C#

C# : I have a panel (with Auto Scroll property true) on which I have many Picture Boxes. I need to get the Picture Boxes location relative to the panel's location. I mean, when I scroll the panel, the Picture Boxes location changes, and I don't want that, I need the Picture Boxes location to remain constant whether I scroll the panel or not. What's the correct way to do that?

panel with Picture Boxes

Is there text that should be scrolling if the pictureboxes should remain on the samen location?

Can you clarify what the scrollbar should do ?

 Dim locX As Integer = PictureBox1.Location.X
 Dim locY As Integer = PictureBox1.Location.Y
 locX -=  Panel1.AutoScrollPosition.X
 locY -= Panel1.AutoScrollPosition.Y
 TextBox1.Text = locX
 TextBox2.Text = locY

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM