By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,054 Members | 1,299 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,054 IT Pros & Developers. It's quick & easy.

Problem in ToolStripComboBoxItem arrow paint (VS.Net 2010, WinForms).

P: 79
I am rendering a toolstrip with a CustomRenderer that inherits from ToolStripProfessionalRenderer. The concept is that I want the color of the arrow of the toolstrip items to be white in all cases except selection. When it is selected the color should be black. In my code below all arrows are painted accordingly except the ToolStripComboBox where the color of the arrow always remains the same; the default one. How to sort it out?

Hope I don't need to write the whole class but only the relevant fragment. So I uploaded the OnRenderArrow method only.

Expand|Select|Wrap|Line Numbers
  1. Friend Class CustomRenderer
  2.     Inherits ToolStripProfessionalRenderer
  4.     Sub New()
  6.     End Sub
  8.     Protected Overrides Sub OnRenderArrow(ByVal e As System.Windows.Forms.ToolStripArrowRenderEventArgs)
  9.         If e.Item.Pressed Then
  10.             e.ArrowColor = Color.White
  11.         ElseIf e.Item.Selected Then
  12.             e.ArrowColor = SystemColors.ControlText
  13.         Else
  14.             e.ArrowColor = Color.White
  15.         End If
  17.         MyBase.OnRenderArrow(e)
  18.     End Sub
  19. End Class
To render the toolstrip with the pertinent class:

Expand|Select|Wrap|Line Numbers
  1. MyToolStrip.Renderer = New CustomRenderer
Aug 4 '12 #1
Share this Question
Share on Google+
1 Reply

P: 79
ToolStripComboBox is a regular combobox that is hosted in a ToolStripControlHost. ToolStripItem arrows is as mentioned the menu children indicators and is not related to that. You may be able to utilize the code to custom paint ComboBox here: Painting right arrow in ToolStripComboBox
Aug 25 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.