RenderMode Property
Collapse the table of content
Expand the table of content

ToolStripManager.RenderMode Property

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; set; }

ExceptionCondition
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;
            }
        }
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2016 Microsoft