GroupBoxRenderer.DrawGroupBox 方法

定义

绘制组框控件。

重载

名称 说明
DrawGroupBox(Graphics, Rectangle, GroupBoxState)

绘制处于指定状态和边界的分组框控件。

DrawGroupBox(Graphics, Rectangle, String, Font, GroupBoxState)

使用指定的文本和字体绘制处于指定状态和边界的分组框控件。

DrawGroupBox(Graphics, Rectangle, String, Font, Color, GroupBoxState)

使用指定的文本、字体和颜色绘制处于指定状态和边界的分组框控件。

DrawGroupBox(Graphics, Rectangle, String, Font, TextFormatFlags, GroupBoxState)

使用指定的文本、字体和文本格式绘制处于指定状态和边界的分组框控件。

DrawGroupBox(Graphics, Rectangle, String, Font, Color, TextFormatFlags, GroupBoxState)

使用指定的文本、字体、颜色和文本格式绘制处于指定状态和边界的分组框控件。

DrawGroupBox(Graphics, Rectangle, GroupBoxState)

Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs

绘制处于指定状态和边界的分组框控件。

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

参数

g
Graphics

Graphics用于绘制组框。

bounds
Rectangle

指定 Rectangle 组框的边界。

state
GroupBoxState

GroupBoxState指定组框视觉状态的值之一。

示例

下面的代码示例使用 DrawGroupBox(Graphics, Rectangle, GroupBoxState) 自定义控件 OnPaint 方法中的方法绘制具有双边框的分组框。 该代码示例是 GroupBoxRenderer 类中的一个较大示例的一部分。

    // Draw the group box in the current state.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override 
    {
        __super::OnPaint(e);

        GroupBoxRenderer::DrawGroupBox(e->Graphics, ClientRectangle,
            this->Text, this->Font, state);

        // Draw an additional inner border if visual styles are enabled.
        if (Application::RenderWithVisualStyles)
        {
            GroupBoxRenderer::DrawGroupBox(e->Graphics, innerRectangle,
                state);
        }
    }
// Draw the group box in the current state.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    GroupBoxRenderer.DrawGroupBox(e.Graphics, ClientRectangle,
        this.Text, this.Font, state);

    // Draw an additional inner border if visual styles are enabled.
    if (Application.RenderWithVisualStyles)
    {
        GroupBoxRenderer.DrawGroupBox(e.Graphics, innerRectangle, state);
    }
}
' Draw the group box in the current state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) 
    MyBase.OnPaint(e)
    
    GroupBoxRenderer.DrawGroupBox(e.Graphics, ClientRectangle, Me.Text, Me.Font, state)
    
    ' Draw an additional inner border if visual styles are enabled.
    If Application.RenderWithVisualStyles Then
        GroupBoxRenderer.DrawGroupBox(e.Graphics, innerRectangle, state)
    End If

End Sub

注解

如果在操作系统中启用了视觉样式,并且视觉样式应用于当前应用程序,此方法将使用当前视觉样式绘制组框。 否则,此方法将使用经典Windows样式绘制组框。

适用于

DrawGroupBox(Graphics, Rectangle, String, Font, GroupBoxState)

Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs

使用指定的文本和字体绘制处于指定状态和边界的分组框控件。

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

参数

g
Graphics

Graphics用于绘制组框。

bounds
Rectangle

指定 Rectangle 组框的边界。

groupBoxText
String

使用 String 组框进行绘制。

font
Font

Font要应用于groupBoxText的 。

state
GroupBoxState

GroupBoxState指定组框视觉状态的值之一。

示例

下面的代码示例使用 DrawGroupBox(Graphics, Rectangle, String, Font, GroupBoxState) 自定义控件 OnPaint 方法中的方法绘制具有双边框的分组框。 该代码示例是 GroupBoxRenderer 类中的一个较大示例的一部分。

    // Draw the group box in the current state.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override 
    {
        __super::OnPaint(e);

        GroupBoxRenderer::DrawGroupBox(e->Graphics, ClientRectangle,
            this->Text, this->Font, state);

        // Draw an additional inner border if visual styles are enabled.
        if (Application::RenderWithVisualStyles)
        {
            GroupBoxRenderer::DrawGroupBox(e->Graphics, innerRectangle,
                state);
        }
    }
// Draw the group box in the current state.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    GroupBoxRenderer.DrawGroupBox(e.Graphics, ClientRectangle,
        this.Text, this.Font, state);

    // Draw an additional inner border if visual styles are enabled.
    if (Application.RenderWithVisualStyles)
    {
        GroupBoxRenderer.DrawGroupBox(e.Graphics, innerRectangle, state);
    }
}
' Draw the group box in the current state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) 
    MyBase.OnPaint(e)
    
    GroupBoxRenderer.DrawGroupBox(e.Graphics, ClientRectangle, Me.Text, Me.Font, state)
    
    ' Draw an additional inner border if visual styles are enabled.
    If Application.RenderWithVisualStyles Then
        GroupBoxRenderer.DrawGroupBox(e.Graphics, innerRectangle, state)
    End If

End Sub

注解

如果在操作系统中启用了视觉样式,并且视觉样式应用于当前应用程序,此方法将使用当前视觉样式绘制组框。 否则,此方法将使用经典Windows样式绘制组框。

适用于

DrawGroupBox(Graphics, Rectangle, String, Font, Color, GroupBoxState)

Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs

使用指定的文本、字体和颜色绘制处于指定状态和边界的分组框控件。

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

参数

g
Graphics

Graphics用于绘制组框。

bounds
Rectangle

指定 Rectangle 组框的边界。

groupBoxText
String

使用 String 组框进行绘制。

font
Font

Font要应用于groupBoxText的 。

textColor
Color

Color要应用于groupBoxText的 。

state
GroupBoxState

GroupBoxState指定组框视觉状态的值之一。

注解

如果在操作系统中启用了视觉样式,并且视觉样式应用于当前应用程序,此方法将使用当前视觉样式绘制组框。 否则,此方法将使用经典Windows样式绘制组框。

适用于

DrawGroupBox(Graphics, Rectangle, String, Font, TextFormatFlags, GroupBoxState)

Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs

使用指定的文本、字体和文本格式绘制处于指定状态和边界的分组框控件。

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

参数

g
Graphics

Graphics用于绘制组框。

bounds
Rectangle

指定 Rectangle 组框的边界。

groupBoxText
String

使用 String 组框进行绘制。

font
Font

Font要应用于groupBoxText的 。

flags
TextFormatFlags

值的按位组合 TextFormatFlags

state
GroupBoxState

GroupBoxState指定组框视觉状态的值之一。

注解

如果在操作系统中启用了视觉样式,并且视觉样式应用于当前应用程序,此方法将使用当前视觉样式绘制组框。 否则,此方法将使用经典Windows样式绘制组框。

适用于

DrawGroupBox(Graphics, Rectangle, String, Font, Color, TextFormatFlags, GroupBoxState)

Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs
Source:
GroupBoxRenderer.cs

使用指定的文本、字体、颜色和文本格式绘制处于指定状态和边界的分组框控件。

public:
 static void DrawGroupBox(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ groupBoxText, System::Drawing::Font ^ font, System::Drawing::Color textColor, System::Windows::Forms::TextFormatFlags flags, System::Windows::Forms::VisualStyles::GroupBoxState state);
public static void DrawGroupBox(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string groupBoxText, System.Drawing.Font font, System.Drawing.Color textColor, System.Windows.Forms.TextFormatFlags flags, System.Windows.Forms.VisualStyles.GroupBoxState state);
public static void DrawGroupBox(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? groupBoxText, System.Drawing.Font? font, System.Drawing.Color textColor, System.Windows.Forms.TextFormatFlags flags, System.Windows.Forms.VisualStyles.GroupBoxState state);
static member DrawGroupBox : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Drawing.Color * System.Windows.Forms.TextFormatFlags * System.Windows.Forms.VisualStyles.GroupBoxState -> unit
Public Shared Sub DrawGroupBox (g As Graphics, bounds As Rectangle, groupBoxText As String, font As Font, textColor As Color, flags As TextFormatFlags, state As GroupBoxState)

参数

g
Graphics

Graphics用于绘制组框。

bounds
Rectangle

指定 Rectangle 组框的边界。

groupBoxText
String

使用 String 组框进行绘制。

font
Font

Font要应用于groupBoxText的 。

textColor
Color

Color要应用于groupBoxText的 。

flags
TextFormatFlags

值的按位组合 TextFormatFlags

state
GroupBoxState

GroupBoxState指定组框视觉状态的值之一。

注解

如果在操作系统中启用了视觉样式,并且视觉样式应用于当前应用程序,此方法将使用当前视觉样式绘制组框。 否则,此方法将使用经典Windows样式绘制组框。

适用于