通过


TabRenderer.DrawTabItem 方法

定义

绘制用于在选项卡控件中选择页面的选项卡。

重载

名称 说明
DrawTabItem(Graphics, Rectangle, TabItemState)

绘制处于指定状态和边界的选项卡。

DrawTabItem(Graphics, Rectangle, Boolean, TabItemState)

绘制处于指定状态和边界的选项卡,并具有可选的焦点矩形。

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

使用指定文本绘制处于指定状态和边界的选项卡。

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

使用指定的图像和可选焦点矩形绘制处于指定状态和边界的选项卡。

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

使用指定的文本和可选焦点矩形绘制处于指定状态和边界的选项卡。

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

使用指定的文本和文本格式以及可选的焦点矩形绘制处于指定状态和边界的选项卡。

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

使用指定的文本和图像以及可选的焦点矩形绘制处于指定状态和边界的选项卡。

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

绘制处于指定状态和边界的选项卡;具有指定文本、文本格式和图像;以及具有可选焦点矩形。

DrawTabItem(Graphics, Rectangle, TabItemState)

Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs

绘制处于指定状态和边界的选项卡。

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)

参数

g
Graphics

Graphics用于绘制选项卡。

bounds
Rectangle

指定 Rectangle 选项卡边界的元素。

state
TabItemState

TabItemState指定选项卡视觉状态的值之一。

例外

操作系统不支持视觉样式。

-或-

操作系统中的用户禁用视觉样式。

-或-

视觉样式不应用于应用程序窗口的工作区。

注解

在调用此方法之前,应验证 IsSupported 属性是否 true返回。

适用于

DrawTabItem(Graphics, Rectangle, Boolean, TabItemState)

Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs

绘制处于指定状态和边界的选项卡,并具有可选的焦点矩形。

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)

参数

g
Graphics

Graphics用于绘制选项卡。

bounds
Rectangle

指定 Rectangle 选项卡边界的元素。

focused
Boolean

true 绘制焦点矩形;否则,为 false.

state
TabItemState

TabItemState指定选项卡视觉状态的值之一。

例外

操作系统不支持视觉样式。

-或-

操作系统中的用户禁用视觉样式。

-或-

视觉样式不应用于应用程序窗口的工作区。

注解

在调用此方法之前,应验证 IsSupported 属性是否 true返回。

适用于

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

Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs

使用指定文本绘制处于指定状态和边界的选项卡。

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)

参数

g
Graphics

Graphics用于绘制选项卡。

bounds
Rectangle

指定 Rectangle 选项卡边界的元素。

tabItemText
String

String 选项卡中绘制的。

font
Font

Font要应用于tabItemText的 。

state
TabItemState

TabItemState指定选项卡视觉状态的值之一。

例外

操作系统不支持视觉样式。

-或-

操作系统中的用户禁用视觉样式。

-或-

视觉样式不应用于应用程序窗口的工作区。

注解

在调用此方法之前,应验证 IsSupported 属性是否 true返回。

适用于

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

Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs

使用指定的图像和可选焦点矩形绘制处于指定状态和边界的选项卡。

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)

参数

g
Graphics

Graphics用于绘制选项卡。

bounds
Rectangle

指定 Rectangle 选项卡边界的元素。

image
Image

Image 选项卡中绘制的。

imageRectangle
Rectangle

指定 Rectangle . 的边界的image

focused
Boolean

true 绘制焦点矩形;否则,为 false.

state
TabItemState

TabItemState指定选项卡视觉状态的值之一。

例外

操作系统不支持视觉样式。

-或-

操作系统中的用户禁用视觉样式。

-或-

视觉样式不应用于应用程序窗口的工作区。

注解

在调用此方法之前,应验证 IsSupported 属性是否 true返回。

适用于

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

Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs

使用指定的文本和可选焦点矩形绘制处于指定状态和边界的选项卡。

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)

参数

g
Graphics

Graphics用于绘制选项卡。

bounds
Rectangle

指定 Rectangle 选项卡边界的元素。

tabItemText
String

String 选项卡中绘制的。

font
Font

Font要应用于tabItemText的 。

focused
Boolean

true 绘制焦点矩形;否则,为 false.

state
TabItemState

TabItemState指定选项卡视觉状态的值之一。

例外

操作系统不支持视觉样式。

-或-

操作系统中的用户禁用视觉样式。

-或-

视觉样式不应用于应用程序窗口的工作区。

示例

下面的代码示例使用 DrawTabItem(Graphics, Rectangle, String, Font, Boolean, TabItemState) 自定义控件 OnPaint 方法中的方法绘制选项卡项。 该代码示例是 TabRenderer 类中的一个较大示例的一部分。

    // 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

注解

在调用此方法之前,应验证 IsSupported 属性是否 true返回。

适用于

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

Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs

使用指定的文本和文本格式以及可选的焦点矩形绘制处于指定状态和边界的选项卡。

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)

参数

g
Graphics

Graphics用于绘制选项卡。

bounds
Rectangle

指定 Rectangle 选项卡边界的元素。

tabItemText
String

String 选项卡中绘制的。

font
Font

Font要应用于tabItemText的 。

flags
TextFormatFlags

值的按位组合 TextFormatFlags

focused
Boolean

true 绘制焦点矩形;否则,为 false.

state
TabItemState

TabItemState指定选项卡视觉状态的值之一。

例外

操作系统不支持视觉样式。

-或-

操作系统中的用户禁用视觉样式。

-或-

视觉样式不应用于应用程序窗口的工作区。

注解

在调用此方法之前,应验证 IsSupported 属性是否 true返回。

适用于

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

Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs

使用指定的文本和图像以及可选的焦点矩形绘制处于指定状态和边界的选项卡。

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)

参数

g
Graphics

Graphics用于绘制选项卡。

bounds
Rectangle

指定 Rectangle 选项卡边界的元素。

tabItemText
String

String 选项卡中绘制的。

font
Font

Font要应用于tabItemText的 。

image
Image

Image 选项卡中绘制的。

imageRectangle
Rectangle

指定 Rectangle . 的边界的image

focused
Boolean

true 绘制焦点矩形;否则,为 false.

state
TabItemState

TabItemState指定选项卡视觉状态的值之一。

例外

操作系统不支持视觉样式。

-或-

操作系统中的用户禁用视觉样式。

-或-

视觉样式不应用于应用程序窗口的工作区。

注解

在调用此方法之前,应验证 IsSupported 属性是否 true返回。

适用于

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

Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs
Source:
TabRenderer.cs

绘制处于指定状态和边界的选项卡;具有指定文本、文本格式和图像;以及具有可选焦点矩形。

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)

参数

g
Graphics

Graphics用于绘制选项卡。

bounds
Rectangle

指定 Rectangle 选项卡边界的元素。

tabItemText
String

String 选项卡中绘制的。

font
Font

Font要应用于tabItemText的 。

flags
TextFormatFlags

值的按位组合 TextFormatFlags

image
Image

Image 选项卡中绘制的。

imageRectangle
Rectangle

指定 Rectangle . 的边界的image

focused
Boolean

true 绘制焦点矩形;否则,为 false.

state
TabItemState

TabItemState指定选项卡视觉状态的值之一。

例外

操作系统不支持视觉样式。

-或-

操作系统中的用户禁用视觉样式。

-或-

视觉样式不应用于应用程序窗口的工作区。

注解

在调用此方法之前,应验证 IsSupported 属性是否 true返回。

适用于