1

I'm working on a program feature in which a FlowLayoutPanel (whose flow direction is set to TopDown) should adjust its width based on whether or not the vertical scrollbar is visible on the screen. I have figured out how to detect if the scrollbar is visible.

My problem is that I can't seem to figure out how to find the width of the (pre-programmed) vertical scrollbar. The reason that I want to expand the panel's width when it overflows is because the scrollbar overlaps the controls in the panel.

If possible, I'd like to avoid changing the margin/padding of the controls, and I would like to avoid using constants that I declare myself in my code.

I'd also like to avoid adding a VerticalScrollBar component, unless there is an easy way to programmatically scroll through the overflown panel based on the scrollbar's thumb position.

Does anyone have any ideas? Thanks!

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
Jeff
  • 227
  • 1
  • 4
  • 16

1 Answers1

2

This is different depending on windows forms and WPF.

System.Windows.Forms.SystemInformation class members: HorizontalScrollBarHeight and VerticalScrollBarWidth.

SystemParameters.VerticalScrollBarWidth

Community
  • 1
  • 1
Philip Stuyck
  • 7,344
  • 3
  • 28
  • 39