Using a custom renderer for toolstrip, but only first button is properly painted
Visual Basic
1
Posts
1
Posters
1
Views
1
Watching
-
I'm using ToolStripProfessionalRenderer to customize a toolstrip. The toolstrip buttons are generated programmatically as needed. The program starts with three buttons. I'm using a LinearGradientBrush to paint the ToolStripButtons, but only the first one (left) gets the gradient. Using the renderer is new to me, so I'm probably missing something obvious.
Private Sub menuRndr_RenderButtonBackground _
(sender As Object, e As ToolStripItemRenderEventArgs) _
Handles Me.RenderButtonBackground
Try
If e.ToolStrip.Equals(main.tabs) Then
Dim p As New Pen(Brushes.Black, 1)Dim lgb As New LinearGradientBrush(e.Item.Bounds, Color.SteelBlue, Color.WhiteSmoke, LinearGradientMode.Vertical) e.Graphics.FillRectangle(lgb, e.Item.Bounds) e.Graphics.DrawRectangle(p, New Rectangle(New Point(e.Item.Bounds.Left, e.Item.Bounds.Top), New Size(e.Item.Bounds.Width, e.Item.Bounds.Height))) End If MyBase.OnRenderItemBackground(e) Catch ex As Exception MsgBox(ex.ToString) End Try End Sub
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.