开发者

How to determine the full size of a Panel (including scroll bars) in C#

开发者 https://www.devze.com 2023-03-24 01:50 出处:网络
The problem I am having is with a panel, which starts at the size 200x200 pixels. For the program I am writing, at any given time I need to know how big this panel is, but this gets difficult as AutoS

The problem I am having is with a panel, which starts at the size 200x200 pixels. For the program I am writing, at any given time I need to know how big this panel is, but this gets difficult as AutoScroll is on and when large content is inserted the panel expands (and gets scroll bars).

I have looked a bit at AutoScrollPosition and AutoScrollOffset, and even 开发者_C百科tried implementing this in my solution - but it appears this only tells you information about the panel when the scroll bar is in a certain position - whereas at any given time I need to know the total size of the panel.

So basically, suppose some content got entered into the panel and taking the scrolling distance into account it really became a 600x750 pixel panel. Does anyone know of any way I can actually get this information?

Thanks


The "including scroll bars" clause makes the question unanswerable. Because the scrollbars are only applied to the DisplayRectangle.

You can get the required size of the panel so that no scrollbars are necessary from the PreferredSize property. You can get the height and width of the scrollbars from the SystemInformation.HorizontalScrollBarHeight and VerticalScrollBarWidth properties.


When the contents of the Panel are bigger than its ClientSize, then AutoScrollMinSize should be equivalent to the scrollable area of the Panel.

0

精彩评论

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

关注公众号