开发者

Get position of label relative to the panel

开发者 https://www.devze.com 2023-02-25 17:36 出处:网络
I have a form with a \'main\' panel. The panel contains lots of labels. The panel itself is larger than the form and is scrollable (Autoscroll = true) . Now I want to Get the position of these labels

I have a form with a 'main' panel. The panel contains lots of labels. The panel itself is larger than the form and is scrollable (Autoscroll = true) . Now I want to Get the position of these labels wrt to the panel , the top left corner of the panel. Not the top left corner currently in view , but the the top left corner of the panel itself.

Label.Left and label.location.X are supposed to give the position relative to the container and they do so too BUT after scrolling the panel down, the (0,0) position of the panel changes to that of of the top lef开发者_如何转开发t corner of the panel currently in view (according to Label.location)

basically I want the get the position of a control(label) relative to its container's top left corner. Control.Location doesn't do that , it gives the location based on the top left corner currently in view ( I think).

any help?

Thanks


You can read the information you need out of the AutoScrollPosition property.

The AutoScrollPosition property represents the location of the visible portion of a scrollable control.

So, the label's position relative to the top left corner of the visible area of the panel is given by label.Location - (Size)panel.AutoScrollPosition.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号