簡體   English   中英

如何在DataGridView控件上獲取滾動條的大小?

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

如何獲得控件上顯示的垂直滾動條的水平和/或寬度(例如DataGridView)?

使用:

SystemInformation.HorizontalScrollBarHeight;
SystemInformation.VerticalScrollBarWidth;

DataGridView上顯示的滾動條與計算機上所有其他滾動條的水平高度和垂直寬度相同。 這些大小由活動Windows主題定義,並由.NET Framework在SystemInformation的以下屬性中公開:

同一類還提供有關當前系統環境中默認滾動條參數的其他信息。


如果您需要知道哪些滾動條是當前可見的控件,使用它的ScrollBars屬性 這將獲取或設置其中一個ScrollBarsNoneHorizontalVerticalBoth

將其放在資源字典中:

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

看一下這個:

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

無論此屬性的值如何,只有在需要時才會顯示滾動條。 使用此屬性可防止出現滾動條。 例如,當您想要提供用於滾動的備用用戶界面(UI)時,這很有用。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM