How to determine the full size of a panel (including scrollbars) in C #

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

I looked at AutoScrollPosition and AutoScrollOffset a bit and even tried to implement this in my solution, but it seems to only tell you the panel information when the scroll bar is at a certain position - whereas at any given time I need to find out the overall size of the panel .

So, in principle, suppose that some content got into the panel and, given the scroll distance, really became a panel of 600x750 pixels in size. Does anyone know how I can get this information?

thanks

+4
source share
2 answers

The sentence "including scroll bars" makes the question irrefutable. Because scrollbars only apply to DisplayRectangle.

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

+4
source

When the contents of the panel are larger than its ClientSize, then AutoScrollMinSize should be equivalent to the scrollable area of ​​the panel.

0
source

All Articles