本文整理汇总了VB.NET中System.Windows.Forms.ListBox.HorizontalExtent属性的典型用法代码示例。如果您正苦于以下问题:VB.NET ListBox.HorizontalExtent属性的具体用法?VB.NET ListBox.HorizontalExtent怎么用?VB.NET ListBox.HorizontalExtent使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.ListBox
的用法示例。
在下文中一共展示了ListBox.HorizontalExtent属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: DisplayHScroll
Private Sub DisplayHScroll()
' Make sure no items are displayed partially.
listBox1.IntegralHeight = True
Dim x As Integer
' Add items that are wide to the ListBox.
For x = 0 To 10
listBox1.Items.Add("Item " + x.ToString() + " is a very large value that requires scroll bars")
Next x
' 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.
Dim g As System.Drawing.Graphics = listBox1.CreateGraphics()
' Determine the size for HorizontalExtent using the MeasureString method using the last item in the list.
Dim hzSize As Integer = g.MeasureString(listBox1.Items(listBox1.Items.Count - 1).ToString(), listBox1.Font).Width
' Set the HorizontalExtent property.
listBox1.HorizontalExtent = hzSize
End Sub