TabRenderer.DrawTabPage(Graphics, Rectangle) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
绘制具有指定边界的选项卡页。
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)
参数
例外
示例
下面的代码示例使用 DrawTabPage 自定义控件的 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
。