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

13,939

Solution 1

Use:

SystemInformation.HorizontalScrollBarHeight;
SystemInformation.VerticalScrollBarWidth;

Solution 2

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:

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.

Share:
13,939
Miko Kronn
Author by

Miko Kronn

Updated on July 29, 2022

Comments

  • Miko Kronn
    Miko Kronn almost 2 years

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