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

久未见 提交于 2019-12-21 11:14:05

问题


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


回答1:


Use:

SystemInformation.HorizontalScrollBarHeight;
SystemInformation.VerticalScrollBarWidth;



回答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:

  • 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.




回答3:


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



来源:https://stackoverflow.com/questions/4462772/how-can-i-get-the-size-of-scrollbars-on-a-datagridview-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!