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

priyamtheone

Well-known member
Joined
Sep 20, 2007
Messages
94
Programming Experience
Beginner
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.
Code:
Friend Class CustomRenderer
    Inherits ToolStripProfessionalRenderer

    Sub New()
        
    End Sub

    Protected Overrides Sub OnRenderArrow(ByVal e As System.Windows.Forms.ToolStripArrowRenderEventArgs)
        If e.Item.Pressed Then
            e.ArrowColor = Color.White
        ElseIf e.Item.Selected Then
            e.ArrowColor = SystemColors.ControlText
        Else
            e.ArrowColor = Color.White
        End If

        MyBase.OnRenderArrow(e)
    End Sub
End Class
To render the toolstrip with the pertinent class:
Code:
MyToolStrip.Renderer = New CustomRenderer
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,283
Location
Sydney, Australia
Programming Experience
10+
Which arrow are you talking about on the combo box? Do you mean the same drop-down arrow that appears on a regular ComboBox control, because that's handled quite differently to the arrows on menu items that indicate that they have children.
 

priyamtheone

Well-known member
Joined
Sep 20, 2007
Messages
94
Programming Experience
Beginner
I'm talking of the drop down arrow that appears to the right of a ToolStripComboBox just like a regular ComboBox control.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,410
Location
Norway
Programming Experience
10+
It is not like a regular ComboBox, it is a regular ComboBox. ToolStripComboBox is ToolStripControlHost that hosts a ComboBox control. 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
 
Top Bottom