TabRenderer.DrawTabItem Method

Definition

Draws a tab that is used to select a page in the tab control.

Overloads

DrawTabItem(Graphics, Rectangle, TabItemState)

Draws a tab in the specified state and bounds.

DrawTabItem(Graphics, Rectangle, Boolean, TabItemState)

Draws a tab in the specified state and bounds, and with an optional focus rectangle.

DrawTabItem(Graphics, Rectangle, String, Font, TabItemState)

Draws a tab in the specified state and bounds, and with the specified text.

DrawTabItem(Graphics, Rectangle, Image, Rectangle, Boolean, TabItemState)

Draws a tab in the specified state and bounds, with the specified image, and with an optional focus rectangle.

DrawTabItem(Graphics, Rectangle, String, Font, Boolean, TabItemState)

Draws a tab in the specified state and bounds, with the specified text, and with an optional focus rectangle.

DrawTabItem(Graphics, Rectangle, String, Font, TextFormatFlags, Boolean, TabItemState)

Draws a tab in the specified state and bounds, with the specified text and text formatting, and with an optional focus rectangle.

DrawTabItem(Graphics, Rectangle, String, Font, Image, Rectangle, Boolean, TabItemState)

Draws a tab in the specified state and bounds, with the specified text and image, and with an optional focus rectangle.

DrawTabItem(Graphics, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, TabItemState)

Draws a tab in the specified state and bounds; with the specified text, text formatting, and image; and with an optional focus rectangle.

DrawTabItem(Graphics, Rectangle, TabItemState)

Draws a tab in the specified state and bounds.

public:
 static void DrawTabItem(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Windows::Forms::VisualStyles::TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.VisualStyles.TabItemState state);
static member DrawTabItem : System.Drawing.Graphics * System.Drawing.Rectangle * System.Windows.Forms.VisualStyles.TabItemState -> unit
Public Shared Sub DrawTabItem (g As Graphics, bounds As Rectangle, state As TabItemState)

Parameters

g
Graphics

The Graphics used to draw the tab.

bounds
Rectangle

The Rectangle that specifies the bounds of the tab.

state
TabItemState

One of the TabItemState values that specifies the visual state of the tab.

Exceptions

The operating system does not support visual styles.

-or-

Visual styles are disabled by the user in the operating system.

-or-

Visual styles are not applied to the client area of application windows.

Remarks

Before calling this method, you should verify that the IsSupported property returns true.

Applies to

DrawTabItem(Graphics, Rectangle, Boolean, TabItemState)

Draws a tab in the specified state and bounds, and with an optional focus rectangle.

public:
 static void DrawTabItem(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, bool focused, System::Windows::Forms::VisualStyles::TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
static member DrawTabItem : System.Drawing.Graphics * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.TabItemState -> unit
Public Shared Sub DrawTabItem (g As Graphics, bounds As Rectangle, focused As Boolean, state As TabItemState)

Parameters

g
Graphics

The Graphics used to draw the tab.

bounds
Rectangle

The Rectangle that specifies the bounds of the tab.

focused
Boolean

true to draw a focus rectangle; otherwise, false.

state
TabItemState

One of the TabItemState values that specifies the visual state of the tab.

Exceptions

The operating system does not support visual styles.

-or-

Visual styles are disabled by the user in the operating system.

-or-

Visual styles are not applied to the client area of application windows.

Remarks

Before calling this method, you should verify that the IsSupported property returns true.

Applies to

DrawTabItem(Graphics, Rectangle, String, Font, TabItemState)

Draws a tab in the specified state and bounds, and with the specified text.

public:
 static void DrawTabItem(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ tabItemText, System::Drawing::Font ^ font, System::Windows::Forms::VisualStyles::TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string tabItemText, System.Drawing.Font font, System.Windows.Forms.VisualStyles.TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? tabItemText, System.Drawing.Font? font, System.Windows.Forms.VisualStyles.TabItemState state);
static member DrawTabItem : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.VisualStyles.TabItemState -> unit
Public Shared Sub DrawTabItem (g As Graphics, bounds As Rectangle, tabItemText As String, font As Font, state As TabItemState)

Parameters

g
Graphics

The Graphics used to draw the tab.

bounds
Rectangle

The Rectangle that specifies the bounds of the tab.

tabItemText
String

The String to draw in the tab.

font
Font

The Font to apply to tabItemText.

state
TabItemState

One of the TabItemState values that specifies the visual state of the tab.

Exceptions

The operating system does not support visual styles.

-or-

Visual styles are disabled by the user in the operating system.

-or-

Visual styles are not applied to the client area of application windows.

Remarks

Before calling this method, you should verify that the IsSupported property returns true.

Applies to

DrawTabItem(Graphics, Rectangle, Image, Rectangle, Boolean, TabItemState)

Draws a tab in the specified state and bounds, with the specified image, and with an optional focus rectangle.

public:
 static void DrawTabItem(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Drawing::Image ^ image, System::Drawing::Rectangle imageRectangle, bool focused, System::Windows::Forms::VisualStyles::TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Drawing.Image image, System.Drawing.Rectangle imageRectangle, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
static member DrawTabItem : System.Drawing.Graphics * System.Drawing.Rectangle * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.TabItemState -> unit
Public Shared Sub DrawTabItem (g As Graphics, bounds As Rectangle, image As Image, imageRectangle As Rectangle, focused As Boolean, state As TabItemState)

Parameters

g
Graphics

The Graphics used to draw the tab.

bounds
Rectangle

The Rectangle that specifies the bounds of the tab.

image
Image

The Image to draw in the tab.

imageRectangle
Rectangle

The Rectangle that specifies the bounds of image.

focused
Boolean

true to draw a focus rectangle; otherwise, false.

state
TabItemState

One of the TabItemState values that specifies the visual state of the tab.

Exceptions

The operating system does not support visual styles.

-or-

Visual styles are disabled by the user in the operating system.

-or-

Visual styles are not applied to the client area of application windows.

Remarks

Before calling this method, you should verify that the IsSupported property returns true.

Applies to

DrawTabItem(Graphics, Rectangle, String, Font, Boolean, TabItemState)

Draws a tab in the specified state and bounds, with the specified text, and with an optional focus rectangle.

public:
 static void DrawTabItem(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ tabItemText, System::Drawing::Font ^ font, bool focused, System::Windows::Forms::VisualStyles::TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string tabItemText, System.Drawing.Font font, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? tabItemText, System.Drawing.Font? font, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
static member DrawTabItem : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * bool * System.Windows.Forms.VisualStyles.TabItemState -> unit
Public Shared Sub DrawTabItem (g As Graphics, bounds As Rectangle, tabItemText As String, font As Font, focused As Boolean, state As TabItemState)

Parameters

g
Graphics

The Graphics used to draw the tab.

bounds
Rectangle

The Rectangle that specifies the bounds of the tab.

tabItemText
String

The String to draw in the tab.

font
Font

The Font to apply to tabItemText.

focused
Boolean

true to draw a focus rectangle; otherwise, false.

state
TabItemState

One of the TabItemState values that specifies the visual state of the tab.

Exceptions

The operating system does not support visual styles.

-or-

Visual styles are disabled by the user in the operating system.

-or-

Visual styles are not applied to the client area of application windows.

Examples

The following code example uses the DrawTabItem(Graphics, Rectangle, String, Font, Boolean, TabItemState) method in a custom control's OnPaint method to draw a tab item. This code example is part of a larger example provided for the TabRenderer class.

    // Draw the tab page and the tab items.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        if (!TabRenderer::IsSupported)
        {
            this->Parent->Text = "CustomTabControl Disabled";
            return;
        }

        TabRenderer::DrawTabPage(e->Graphics, tabPageRectangle);
        TabRenderer::DrawTabItem(e->Graphics, tabItemRectangle1,
            tab1Text, this->Font, tab1Focused, tab1State);
        TabRenderer::DrawTabItem(e->Graphics, tabItemRectangle2,
            tab2Text, this->Font, tab2Focused, tab2State);

        this->Parent->Text = "CustomTabControl Enabled";
    }
// Draw the tab page and the tab items.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    if (!TabRenderer.IsSupported)
    {
        this.Parent.Text = "CustomTabControl Disabled";
        return;
    }

    TabRenderer.DrawTabPage(e.Graphics, tabPageRectangle);
    TabRenderer.DrawTabItem(e.Graphics, tabItemRectangle1,
        tab1Text, this.Font, tab1Focused, tab1State);
    TabRenderer.DrawTabItem(e.Graphics, tabItemRectangle2,
        tab2Text, this.Font, tab2Focused, tab2State);

    this.Parent.Text = "CustomTabControl Enabled";
}
' Draw the tab page and the tab items.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    If Not TabRenderer.IsSupported Then
        Me.Parent.Text = "CustomTabControl Disabled"
        Return
    End If

    TabRenderer.DrawTabPage(e.Graphics, tabPageRectangle)
    TabRenderer.DrawTabItem(e.Graphics, tabItemRectangle1, _
        tab1Text, Me.Font, tab1Focused, tab1State)
    TabRenderer.DrawTabItem(e.Graphics, tabItemRectangle2, _
        tab2Text, Me.Font, tab2Focused, tab2State)
    Me.Parent.Text = "CustomTabControl Enabled"
End Sub

Remarks

Before calling this method, you should verify that the IsSupported property returns true.

Applies to

DrawTabItem(Graphics, Rectangle, String, Font, TextFormatFlags, Boolean, TabItemState)

Draws a tab in the specified state and bounds, with the specified text and text formatting, and with an optional focus rectangle.

public:
 static void DrawTabItem(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ tabItemText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, bool focused, System::Windows::Forms::VisualStyles::TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string tabItemText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? tabItemText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
static member DrawTabItem : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.TextFormatFlags * bool * System.Windows.Forms.VisualStyles.TabItemState -> unit
Public Shared Sub DrawTabItem (g As Graphics, bounds As Rectangle, tabItemText As String, font As Font, flags As TextFormatFlags, focused As Boolean, state As TabItemState)

Parameters

g
Graphics

The Graphics used to draw the tab.

bounds
Rectangle

The Rectangle that specifies the bounds of the tab.

tabItemText
String

The String to draw in the tab.

font
Font

The Font to apply to tabItemText.

flags
TextFormatFlags

A bitwise combination of the TextFormatFlags values.

focused
Boolean

true to draw a focus rectangle; otherwise, false.

state
TabItemState

One of the TabItemState values that specifies the visual state of the tab.

Exceptions

The operating system does not support visual styles.

-or-

Visual styles are disabled by the user in the operating system.

-or-

Visual styles are not applied to the client area of application windows.

Remarks

Before calling this method, you should verify that the IsSupported property returns true.

Applies to

DrawTabItem(Graphics, Rectangle, String, Font, Image, Rectangle, Boolean, TabItemState)

Draws a tab in the specified state and bounds, with the specified text and image, and with an optional focus rectangle.

public:
 static void DrawTabItem(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ tabItemText, System::Drawing::Font ^ font, System::Drawing::Image ^ image, System::Drawing::Rectangle imageRectangle, bool focused, System::Windows::Forms::VisualStyles::TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string tabItemText, System.Drawing.Font font, System.Drawing.Image image, System.Drawing.Rectangle imageRectangle, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? tabItemText, System.Drawing.Font? font, System.Drawing.Image image, System.Drawing.Rectangle imageRectangle, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
static member DrawTabItem : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.TabItemState -> unit
Public Shared Sub DrawTabItem (g As Graphics, bounds As Rectangle, tabItemText As String, font As Font, image As Image, imageRectangle As Rectangle, focused As Boolean, state As TabItemState)

Parameters

g
Graphics

The Graphics used to draw the tab.

bounds
Rectangle

The Rectangle that specifies the bounds of the tab.

tabItemText
String

The String to draw in the tab.

font
Font

The Font to apply to tabItemText.

image
Image

The Image to draw in the tab.

imageRectangle
Rectangle

The Rectangle that specifies the bounds of image.

focused
Boolean

true to draw a focus rectangle; otherwise, false.

state
TabItemState

One of the TabItemState values that specifies the visual state of the tab.

Exceptions

The operating system does not support visual styles.

-or-

Visual styles are disabled by the user in the operating system.

-or-

Visual styles are not applied to the client area of application windows.

Remarks

Before calling this method, you should verify that the IsSupported property returns true.

Applies to

DrawTabItem(Graphics, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, TabItemState)

Draws a tab in the specified state and bounds; with the specified text, text formatting, and image; and with an optional focus rectangle.

public:
 static void DrawTabItem(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ tabItemText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, System::Drawing::Image ^ image, System::Drawing::Rectangle imageRectangle, bool focused, System::Windows::Forms::VisualStyles::TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string tabItemText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageRectangle, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
public static void DrawTabItem (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? tabItemText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageRectangle, bool focused, System.Windows.Forms.VisualStyles.TabItemState state);
static member DrawTabItem : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.TextFormatFlags * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.TabItemState -> unit
Public Shared Sub DrawTabItem (g As Graphics, bounds As Rectangle, tabItemText As String, font As Font, flags As TextFormatFlags, image As Image, imageRectangle As Rectangle, focused As Boolean, state As TabItemState)

Parameters

g
Graphics

The Graphics used to draw the tab.

bounds
Rectangle

The Rectangle that specifies the bounds of the tab.

tabItemText
String

The String to draw in the tab.

font
Font

The Font to apply to tabItemText.

flags
TextFormatFlags

A bitwise combination of the TextFormatFlags values.

image
Image

The Image to draw in the tab.

imageRectangle
Rectangle

The Rectangle that specifies the bounds of image.

focused
Boolean

true to draw a focus rectangle; otherwise, false.

state
TabItemState

One of the TabItemState values that specifies the visual state of the tab.

Exceptions

The operating system does not support visual styles.

-or-

Visual styles are disabled by the user in the operating system.

-or-

Visual styles are not applied to the client area of application windows.

Remarks

Before calling this method, you should verify that the IsSupported property returns true.

Applies to