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)

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

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 值之一。

示例

下面的代码示例在自定义控件的 OnPaint 方法中使用 DrawGroupBox(Graphics, Rectangle, GroupBoxState) 方法绘制具有双边框的分组框。 此代码示例是为 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)

绘制具有指定的状态和边界以及指定的文本和字体的分组框控件。

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

要应用于 groupBoxTextFont

state
GroupBoxState

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

示例

下面的代码示例在自定义控件的 OnPaint 方法中使用 DrawGroupBox(Graphics, Rectangle, String, Font, GroupBoxState) 方法绘制具有双边框的分组框。 此代码示例是为 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)

绘制具有指定的状态和边界以及指定的文本、字体和颜色的分组框控件。

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

要应用于 groupBoxTextFont

textColor
Color

要应用于 groupBoxTextColor

state
GroupBoxState

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

注解

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

适用于

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

绘制具有指定的状态和边界以及指定的文本、字体和文本格式的分组框控件。

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

要应用于 groupBoxTextFont

flags
TextFormatFlags

TextFormatFlags 值的按位组合。

state
GroupBoxState

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

注解

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

适用于

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

绘制具有指定的状态和边界以及指定的文本、字体、颜色和文本格式的分组框控件。

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

要应用于 groupBoxTextFont

textColor
Color

要应用于 groupBoxTextColor

flags
TextFormatFlags

TextFormatFlags 值的按位组合。

state
GroupBoxState

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

注解

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

适用于