本文整理汇总了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