ToolStripManager.RenderMode Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the default theme for the form.

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

public static ToolStripManagerRenderMode RenderMode {
	get;
	[UIPermissionAttribute(SecurityAction.Demand, Window = UIPermissionWindow.AllWindows)]
	set;
}

Exception Condition
InvalidEnumArgumentException

The set value was not one of the ToolStripManagerRenderMode values.

NotSupportedException

ToolStripManagerRenderMode is set to Custom; use the Renderer property instead.

Use the RenderMode property to get or set whether the application is painted by the ToolStripProfessionalRenderer, the ToolStripSystemRenderer, or a customized ToolStripRenderer.

The following code example demonstrates a use of the RenderMode property. This example is part of a larger example provided for the Renderer property.

// This event handler is invoked when 
// the "Apply Renderers" button is clicked.
// Depending on the value selected in a ComboBox control,
// it applies a custom renderer selectively to
// individual MenuStrip or ToolStrip controls,
// or it applies a custom renderer to the 
// application as a whole.
void applyButton_Click(object sender, EventArgs e)
{
    ToolStrip ms = ToolStripManager.FindToolStrip("MenuStrip");
    ToolStrip ts = ToolStripManager.FindToolStrip("ToolStrip");

    if (targetComboBox.SelectedItem != null)
    {
        switch (targetComboBox.SelectedItem.ToString())
        {
            case "Reset":
            {
                ms.RenderMode = ToolStripRenderMode.ManagerRenderMode;
                ts.RenderMode = ToolStripRenderMode.ManagerRenderMode;

                // Set the default RenderMode to Professional.
                ToolStripManager.RenderMode = ToolStripManagerRenderMode.Professional;

                break;
            }

            case "All":
            {
                ms.RenderMode = ToolStripRenderMode.ManagerRenderMode;
                ts.RenderMode = ToolStripRenderMode.ManagerRenderMode;

                // Assign the custom renderer at the application level.
                ToolStripManager.Renderer = new CustomProfessionalRenderer();

                break;
            }

            case "MenuStrip":
            {
                // Assign the custom renderer to the MenuStrip control only.
                ms.Renderer = new CustomProfessionalRenderer();

                break;
            }

            case "ToolStrip":
            {
                // Assign the custom renderer to the ToolStrip control only.
                ts.Renderer = new CustomProfessionalRenderer();

                break;
            }
        }
    }
}

.NET Framework
Available since 2.0
Return to top
Show: