ToolStripManager.RenderMode Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the default theme for the form.
public:
static property System::Windows::Forms::ToolStripManagerRenderMode RenderMode { System::Windows::Forms::ToolStripManagerRenderMode get(); void set(System::Windows::Forms::ToolStripManagerRenderMode value); };
public static System.Windows.Forms.ToolStripManagerRenderMode RenderMode { get; set; }
static member RenderMode : System.Windows.Forms.ToolStripManagerRenderMode with get, set
Public Shared Property RenderMode As ToolStripManagerRenderMode
One of the ToolStripManagerRenderMode values.
The set value was not one of the ToolStripManagerRenderMode values.
ToolStripManagerRenderMode is set to Custom; use the Renderer property instead.
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;
}
}
}
}
' 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.
Sub applyButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim ms As ToolStrip = ToolStripManager.FindToolStrip("MenuStrip")
Dim ts As ToolStrip = ToolStripManager.FindToolStrip("ToolStrip")
If targetComboBox.SelectedItem IsNot Nothing Then
Select Case targetComboBox.SelectedItem.ToString()
Case "Reset"
ms.RenderMode = ToolStripRenderMode.ManagerRenderMode
ts.RenderMode = ToolStripRenderMode.ManagerRenderMode
' Set the default RenderMode to Professional.
ToolStripManager.RenderMode = ToolStripManagerRenderMode.Professional
Exit Select
Case "All"
ms.RenderMode = ToolStripRenderMode.ManagerRenderMode
ts.RenderMode = ToolStripRenderMode.ManagerRenderMode
' Assign the custom renderer at the application level.
ToolStripManager.Renderer = New CustomProfessionalRenderer()
Exit Select
Case "MenuStrip"
' Assign the custom renderer to the MenuStrip control only.
ms.Renderer = New CustomProfessionalRenderer()
Exit Select
Case "ToolStrip"
' Assign the custom renderer to the ToolStrip control only.
ts.Renderer = New CustomProfessionalRenderer()
Exit Select
End Select
End If
End Sub
Use the RenderMode property to get or set whether the application is painted by the ToolStripProfessionalRenderer, the ToolStripSystemRenderer, or a customized ToolStripRenderer.
Termék | Verziók |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET-visszajelzés
A(z) .NET egy nyílt forráskód projekt. Visszajelzés adásához válasszon egy hivatkozást: