Miko Kronn
Miko Kronn

Reputation: 2454

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)?

Upvotes: 8

Views: 15518

Answers (3)

THE DOCTOR
THE DOCTOR

Reputation: 4555

Place this in your resource dictionary:

<xcdg:DataGridControl >
<xcdg:DataGridControl.Resources>
<Style TargetType="{x:Type xcdg:TableViewScrollViewer}">
<Setter Property="VerticalScrollBarVisibility" Value="Hidden" />
</Style>
</xcdg:DataGridControl>

check this out:

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.scrollbars.aspx

Regardless of the value of this property, scroll bars are shown only when they are needed. Use this property to prevent scroll bars from appearing. This is useful, for example, when you want to provide an alternative user interface (UI) for scrolling.

http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollbars.aspx

Upvotes: -2

Darren Young
Darren Young

Reputation: 11100

Use:

SystemInformation.HorizontalScrollBarHeight;
SystemInformation.VerticalScrollBarWidth;

Upvotes: 17

Cody Gray
Cody Gray

Reputation: 244981

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.

Upvotes: 7

Related Questions