--- title: "How to: Render a Visual Style Element" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" - "cpp" helpviewer_keywords: - "visual themes [Windows Forms], applying to elements of Windows Forms applications" - "professional appearance [Windows Forms], applying to elements of Windows Forms applications" - "visual styles [Windows Forms], rendering Windows Forms controls" ms.assetid: a207781b-1baa-4ce9-b788-1e951bd4b5df --- # How to: Render a Visual Style Element The namespace exposes objects that represent the Windows user interface (UI) elements supported by visual styles. This topic demonstrates how to use the class to render the that represents the **Log Off** and **Shut Down** buttons of the Start menu. ### To render a visual style element 1. Create a and set it to the element you want to draw. Note the use of the property and the method; the constructor will throw an exception if visual styles are disabled or an element is undefined. [!code-cpp[System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple#4](~/samples/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple/cpp/form1.cpp#4)] [!code-csharp[System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple#4](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple/CS/form1.cs#4)] [!code-vb[System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple#4](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple/VB/form1.vb#4)] 2. Call the method to render the element that the currently represents. [!code-cpp[System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple#6](~/samples/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple/cpp/form1.cpp#6)] [!code-csharp[System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple#6](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple/CS/form1.cs#6)] [!code-vb[System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple#6](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.VisualStyles.VisualStyleRenderer_Simple/VB/form1.vb#6)] ## Compiling the Code This example requires: - A custom control derived from the class. - A that hosts the custom control. - References to the , , , and namespaces. ## See also - [Rendering Controls with Visual Styles](rendering-controls-with-visual-styles.md)