简体   繁体   English

如何在自动滚动面板中获取控件的位置? C#

[英]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. C#:我有一个面板(自动滚动属性为true),上面有许多图片框。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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