我凌驾于<代码>之上。 On RenderButtonBackground 为了使用习俗彩色的方法,但我想知道,该 mo是否目前位于纽特州。
我试图获得母体控制(工具组合)和母体形式,并增加所有协调机构,但这不正确:
Private Class MyRenderer
Inherits ToolStripProfessionalRenderer
Protected Overrides Sub OnRenderButtonBackground(e As ToolStripItemRenderEventArgs)
Dim btn = TryCast(e.Item, ToolStripButton)
If Not btn Is Nothing AndAlso btn.Checked Then
Dim bounds As New Rectangle(Point.Empty, e.Item.Size)
Dim ts As ToolStrip = e.Item.GetCurrentParent
Dim f As Form = CType(e.Item.GetCurrentParent.GetContainerControl, Form)
Dim btnRect As New Rectangle(f.Location.X + ts.Location.X + e.Item.Bounds.X, f.Location.Y + ts.Location.Y + e.Item.Bounds.Y, e.Item.Bounds.Width, e.Item.Bounds.Height)
If btnRect.Contains(MousePosition) Then
doesn t reach this path...
e.Graphics.FillRectangle(New SolidBrush(Color.Blue), bounds)
Else
e.Graphics.FillRectangle(New SolidBrush(Color.Red), bounds)
End If
Else
MyBase.OnRenderButtonBackground(e)
End If
End Sub
End Class
我确信,这样做必须有更简单的方式?