本文整理汇总了C#中System.Windows.Forms.ListBox.IntegralHeight属性的典型用法代码示例。如果您正苦于以下问题:C# ListBox.IntegralHeight属性的具体用法?C# ListBox.IntegralHeight怎么用?C# ListBox.IntegralHeight使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.ListBox
的用法示例。
在下文中一共展示了ListBox.IntegralHeight属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayHScroll
private void DisplayHScroll()
{
// Make sure no items are displayed partially.
listBox1.IntegralHeight = true;
// Add items that are wide to the ListBox.
for (int x = 0; x < 10; x++)
{
listBox1.Items.Add("Item " + x.ToString() + " is a very large value that requires scroll bars");
}
// Display a horizontal scroll bar.
listBox1.HorizontalScrollbar = true;
// Create a Graphics object to use when determining the size of the largest item in the ListBox.
Graphics g = listBox1.CreateGraphics();
// Determine the size for HorizontalExtent using the MeasureString method using the last item in the list.
int hzSize = (int) g.MeasureString(listBox1.Items[listBox1.Items.Count -1].ToString(),listBox1.Font).Width;
// Set the HorizontalExtent property.
listBox1.HorizontalExtent = hzSize;
}