本文整理匯總了VB.NET中System.Windows.Forms.ToolStripItem.ContentRectangle屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET ToolStripItem.ContentRectangle屬性的具體用法?VB.NET ToolStripItem.ContentRectangle怎麽用?VB.NET ToolStripItem.ContentRectangle使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Windows.Forms.ToolStripItem
的用法示例。
在下文中一共展示了ToolStripItem.ContentRectangle屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: ComputeImageAndTextLayout
' This utility method computes the layout of the
' RolloverItem control's image area and the text area.
' For brevity, only the following settings are
' supported:
'
' ToolStripTextDirection.Horizontal
' TextImageRelation.ImageBeforeText
' TextImageRelation.ImageBeforeText
'
' It would not be difficult to support vertical text
' directions and other image/text relationships.
Private Sub ComputeImageAndTextLayout()
Dim cr As Rectangle = MyBase.ContentRectangle
Dim img As Image = MyBase.Owner.ImageList.Images(MyBase.ImageKey)
' Compute the center of the item's ContentRectangle.
Dim centerY As Integer = CInt((cr.Height - img.Height) / 2)
' Find the dimensions of the image and the text
' areas of the item. The text occupies the space
' not filled by the image.
If MyBase.TextImageRelation = _
TextImageRelation.ImageBeforeText AndAlso _
MyBase.TextDirection = ToolStripTextDirection.Horizontal Then
imageRect = New Rectangle( _
MyBase.ContentRectangle.Left, _
centerY, _
MyBase.Image.Width, _
MyBase.Image.Height)
textRect = New Rectangle( _
imageRect.Width, _
MyBase.ContentRectangle.Top, _
MyBase.ContentRectangle.Width - imageRect.Width, _
MyBase.ContentRectangle.Height)
ElseIf MyBase.TextImageRelation = _
TextImageRelation.TextBeforeImage AndAlso _
MyBase.TextDirection = ToolStripTextDirection.Horizontal Then
imageRect = New Rectangle( _
MyBase.ContentRectangle.Right - MyBase.Image.Width, _
centerY, _
MyBase.Image.Width, _
MyBase.Image.Height)
textRect = New Rectangle( _
MyBase.ContentRectangle.Left, _
MyBase.ContentRectangle.Top, _
imageRect.X, _
MyBase.ContentRectangle.Bottom)
End If
End Sub
End Class