Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Using a custom renderer for toolstrip, but only first button is properly painted

Using a custom renderer for toolstrip, but only first button is properly painted

Scheduled Pinned Locked Moved Visual Basic
graphicscareer
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alan Burkhart
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups