How to render a control to look like ComboBox with Visual Styles enabled?

I’m not 100% sure if this is what you are looking for but you should check out the VisualStyleRenderer in the System.Windows.Forms.VisualStyles-namespace.

  1. VisualStyleRenderer class (MSDN)
  2. How to: Render a Visual Style Element (MSDN)
  3. VisualStyleElement.ComboBox.DropDownButton.Disabled (MSDN)

Since VisualStyleRenderer won’t work if the user don’t have visual styles enabled (he/she might be running ‘classic mode’ or an operative system prior to Windows XP) you should always have a fallback to the ControlPaint class.

// Create the renderer.
if (VisualStyleInformation.IsSupportedByOS 
    && VisualStyleInformation.IsEnabledByUser) 
{
    renderer = new VisualStyleRenderer(
        VisualStyleElement.ComboBox.DropDownButton.Disabled);
}

and then do like this when drawing:

if(renderer != null)
{
    // Use visual style renderer.
}
else
{
    // Use ControlPaint renderer.
}

Hope it helps!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)