The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ComboBoxRenderer Class

Provides methods used to render a combo box control with visual styles. This class cannot be inherited.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public sealed class ComboBoxRenderer
public final class ComboBoxRenderer
public final class ComboBoxRenderer
Not applicable.

The ComboBoxRenderer class provides a set of static methods that can be used to render a combo box control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a combo box, use the DrawTextBox method to draw the text box and the DrawDropDownButton method to draw the drop-down arrow.

If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, DrawTextBox and DrawDropDownButton will draw the combo box with the current visual style. Otherwise, these methods will throw an InvalidOperationException. To determine whether the members of this class can be used, you can check the value of the IsSupported property.

This class wraps the functionality of a System.Windows.Forms.VisualStyles.VisualStyleRenderer that is set to one of the elements exposed by the System.Windows.Forms.VisualStyles.VisualStyleElement.ComboBox.DropDownButton and System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox.TextEdit classes. For more information, see Rendering Controls with Visual Styles.

Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: Visual styles are supported only on these platforms.

The following code example demonstrates how to create a custom control that uses the DrawTextBox and DrawDropDownButton methods to draw a combo box that responds to mouse clicks.

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

namespace ComboBoxRendererSample
    class Form1 : Form
        public Form1()
            : base()
            this.Size = new Size(300, 300);
            CustomComboBox ComboBox1 = new CustomComboBox();

        static void Main()
            // The call to EnableVisualStyles below does not affect
            // whether ComboBoxRenderer.IsSupported is true; as long as visual
            // styles are enabled by the operating system, IsSupported is true.
            Application.Run(new Form1());

    public class CustomComboBox : Control
        private Size arrowSize;
        private Rectangle arrowRectangle;
        private Rectangle topTextBoxRectangle;
        private Rectangle bottomTextBoxRectangle;
        private ComboBoxState textBoxState = ComboBoxState.Normal;
        private ComboBoxState arrowState = ComboBoxState.Normal;
        private String bottomText = "Using ComboBoxRenderer";
        private bool isActivated = false;
        private const int minHeight = 38;
        private const int minWidth = 40;

        public CustomComboBox()
            : base()
            this.Location = new Point(10, 10);
            this.Size = new Size(140, 38);
            this.Font = SystemFonts.IconTitleFont;
            this.Text = "Click the button";

            // Initialize the rectangles to look like the standard combo 
            // box control.
            arrowSize = new Size(18, 20);
            arrowRectangle = new Rectangle(ClientRectangle.X +
                ClientRectangle.Width - arrowSize.Width - 1,
                ClientRectangle.Y + 1,
            topTextBoxRectangle = new Rectangle(ClientRectangle.X,
                arrowSize.Height + 2);
            bottomTextBoxRectangle = new Rectangle(ClientRectangle.X,
                ClientRectangle.Y + topTextBoxRectangle.Height,
                topTextBoxRectangle.Height - 6);

        // Draw the combo box in the current state.
        protected override void OnPaint(PaintEventArgs e)

            if (!ComboBoxRenderer.IsSupported)
                this.Parent.Text = "Visual Styles Disabled";

            this.Parent.Text = "CustomComboBox Enabled";

            // Always draw the main text box and drop down arrow in their 
            // current states
            ComboBoxRenderer.DrawTextBox(e.Graphics, topTextBoxRectangle,
                this.Text, this.Font, textBoxState);
            ComboBoxRenderer.DrawDropDownButton(e.Graphics, arrowRectangle,

            // Only draw the bottom text box if the arrow has been clicked
            if (isActivated)
                    bottomTextBoxRectangle, bottomText, this.Font,

        protected override void OnMouseDown(MouseEventArgs e)

            // Check whether the user clicked the arrow.
            if (arrowRectangle.Contains(e.Location) &&
                // Draw the arrow in the pressed state.
                arrowState = ComboBoxState.Pressed;

                // The user has activated the combo box.
                if (!isActivated)
                    this.Text = "Clicked!";
                    textBoxState = ComboBoxState.Pressed;
                    isActivated = true;

                // The user has deactivated the combo box.
                    this.Text = "Click here";
                    textBoxState = ComboBoxState.Normal;
                    isActivated = false;

                // Redraw the control.

        protected override void OnMouseUp(MouseEventArgs e)

            if (arrowRectangle.Contains(e.Location) &&
                arrowState = ComboBoxState.Normal;


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0