本文整理匯總了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