views:

252

answers:

2

Does anyone know if, and how I am able to change the colour of the image strip on a simple drop down in visual studio 2008? Currently with a drop down menu i have my own collectn of items, and beside each on the drop down menu is an image strip, which is curently a grey colour with a light to dark gradient. I am eager to find out if this colour can be changed or possibly removed altogether? Thanks in advance guys, Craig.

+1  A: 

You can realize this behavior by creating a subclass of ToolStripRenderer and overriding the appropriate rendering methods. See MSDN for examples.

I am assuming you are looking for a WinForms solution. For WPF/Xaml the solution is of course completely different and can be accomplished by changing the control templates.

Rine
A: 

I'm going to assume you're asking about winforms, as I don't know about WPF.

If you just want to hide the image strip, you can set the ShowImageMargin and ShowCheckMargin properties to false. However, you won't be able to display images for your menu items.

On XP at least, setting the RenderMode property of the dropdown to ToolStripRenderMode.System will give you a menu without any image margin decoration; though it may not match the visual style of your application.

If you set a BackColor for each of your menu items, the image margin will be obscured.

To hide the image margin without changing the visual style of the dropdown, you'll need to create a renderer with an empty OnRenderImageMargin function, like so:

class MyRenderer : ToolStripProfessionalRenderer
{
    protected virtual void OnRenderImageMargin(ToolStripRenderEventArgs e)
    {
        // do nothing
    }
}

and then set the dropdown's Renderer property to an instance of the new renderer class. You could change the colour of the image margin in a similar manner by modifying the renderer's ColorTable.

But, before you do any of those, ask yourself:

  • Is there a usability benefit to changing the interface to something less familiar?
  • If there is, is this benefit greater than the benefit of keeping your code simple so you can respond quickly to user feedback?

The answer to the first question is usually 'No'.

Simon
Thanks simon, il give it a blast nd see what i can do!!