TabRenderer.DrawTabPage(Graphics, Rectangle) TabRenderer.DrawTabPage(Graphics, Rectangle) TabRenderer.DrawTabPage(Graphics, Rectangle) TabRenderer.DrawTabPage(Graphics, Rectangle) Method

定义

绘制具有指定边界的选项卡页。Draws a tab page in the specified bounds.

public:
 static void DrawTabPage(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds);
public static void DrawTabPage (System.Drawing.Graphics g, System.Drawing.Rectangle bounds);
static member DrawTabPage : System.Drawing.Graphics * System.Drawing.Rectangle -> unit
Public Shared Sub DrawTabPage (g As Graphics, bounds As Rectangle)

参数

g
Graphics Graphics Graphics Graphics

用于绘制选项卡页的 GraphicsThe Graphics used to draw the tab page.

bounds
Rectangle Rectangle Rectangle Rectangle

用于指定选项卡页边界的 RectangleThe Rectangle that specifies the bounds of the tab page.

异常

操作系统不支持视觉样式。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.

示例

下面的代码示例使用DrawTabPage方法在自定义控件的OnPaint方法,以便绘制选项卡页。The following code example uses the DrawTabPage method in a custom control's OnPaint method to draw a tab page. 此代码示例是为提供一个更大示例的一部分TabRenderer类。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

注解

调用此方法之前,应验证IsSupported属性返回trueBefore calling this method, you should verify that the IsSupported property returns true.

适用于