本文整理汇总了VB.NET中System.Windows.Forms.ButtonRenderer.DrawButton方法的典型用法代码示例。如果您正苦于以下问题:VB.NET ButtonRenderer.DrawButton方法的具体用法?VB.NET ButtonRenderer.DrawButton怎么用?VB.NET ButtonRenderer.DrawButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ButtonRenderer
的用法示例。
在下文中一共展示了ButtonRenderer.DrawButton方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: OnPaint
' Draw the large or small button, depending on the current state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
' Draw the smaller pressed button image.
If state = PushButtonState.Pressed Then
' Set the background color to the parent if visual styles
' are disabled, because DrawParentBackground will only paint
' over the control background if visual styles are enabled.
If Application.RenderWithVisualStyles Then
Me.BackColor = Color.Azure
Else
Me.BackColor = Me.Parent.BackColor
End If
' If you comment out the call to DrawParentBackground,
' the background of the control will still be visible
' outside the pressed button, if visual styles are enabled.
ButtonRenderer.DrawParentBackground(e.Graphics, _
Me.ClientRectangle, Me)
ButtonRenderer.DrawButton(e.Graphics, ClickRectangle, _
Me.Text, Me.Font, True, state)
' Draw the bigger unpressed button image.
Else
ButtonRenderer.DrawButton(e.Graphics, Me.ClientRectangle, _
Me.Text, Me.Font, False, state)
End If
End Sub
' Draw the smaller pressed button image.
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseDown(e)
With Me
.Text = "Clicked!"
.state = PushButtonState.Pressed
End With
Invalidate()
End Sub
' Draw the button in the hot state.
Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
With Me
.Text = "Click here"
.state = PushButtonState.Hot
End With
Invalidate()
End Sub
' Draw the button in the unpressed state.
Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
MyBase.OnMouseLeave(e)
With Me
.Text = "Click here"
.state = PushButtonState.Normal
End With
Invalidate()
End Sub