Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the size of scrollbars on a DataGridView control?

How can I get the height of horizontal and/or width of vertical scrollbar that appears on control (e.g. DataGridView)?

like image 713
Miko Kronn Avatar asked Dec 16 '10 16:12

Miko Kronn


People also ask

How do I find out my scrollbar size?

To get the width of the scrollbar, you use the offsetWidth and clientWidth of the Element : The offsetWidth returns the width of the Element in pixels including the scrollbar. The clientWidth returns the with of the Element in pixels without the scrollbar.

What is the size of the scrollbar?

The default scrollbar width can range anywhere from 12px to 17px.


2 Answers

Use:

SystemInformation.HorizontalScrollBarHeight;
SystemInformation.VerticalScrollBarWidth;
like image 166
Darren Young Avatar answered Oct 18 '22 18:10

Darren Young


The scrollbars that appear on your DataGridView will be the same horizontal height and vertical width as all of the other scrollbars on your computer. These sizes are defined by the active Windows theme, and exposed by the .NET Framework in the following properties of the SystemInformation class:

  • VerticalScrollBarWidth
  • HorizontalScrollBarHeight

The same class also provides additional information about the default scrollbar parameters in the current system environment.


If you need to know which scrollbars are currently visible on your control, use its ScrollBars property. This gets or sets one of the ScrollBars values, either None, Horizontal, Vertical, or Both.

like image 45
Cody Gray Avatar answered Oct 18 '22 18:10

Cody Gray