CheckBoxRenderer.DrawCheckBox Methode

Definition

Zeichnet ein Kontrollkästchen-Steuerelement.

Überlädt

DrawCheckBox(Graphics, Point, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position.

DrawCheckBox(Graphics, Point, Rectangle, String, Font, Boolean, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position, mit dem angegebenen Text und mit einem optionalen Fokusrechteck.

DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Boolean, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position, mit dem angegebenen Text und der angegebenen Textformatierung und mit einem optionalen Fokusrechteck.

DrawCheckBox(Graphics, Point, Rectangle, String, Font, Image, Rectangle, Boolean, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position, mit dem angegebenen Text und Bild und mit einem optionalen Fokusrechteck.

DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position, mit dem angegebenen Text, der angegebenen Textformatierung und dem angegebenen Bild sowie mit einem optionalen Fokusrechteck.

DrawCheckBox(Graphics, Point, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, state As CheckBoxState)

Parameter

g
Graphics

Die zum Zeichnen des Kontrollkästchens verwendete Graphics.

glyphLocation
Point

Der Point, an dem das Symbol für das Kontrollkästchen gezeichnet werden soll.

state
CheckBoxState

Einer der CheckBoxState-Werte, der den visuellen Zustand des Kontrollkästchens angibt.

Hinweise

Wenn visuelle Formatvorlagen im Betriebssystem aktiviert sind und visuelle Formatvorlagen auf die aktuelle Anwendung angewendet werden, zeichnet diese Methode das Kontrollkästchen mit der aktuellen visuellen Formatvorlage. Andernfalls wird das Kontrollkästchen mit dem klassischen Windows-Format gezeichnet.

Gilt für

DrawCheckBox(Graphics, Point, Rectangle, String, Font, Boolean, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position, mit dem angegebenen Text und mit einem optionalen Fokusrechteck.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Drawing::Rectangle textBounds, System::String ^ checkBoxText, System::Drawing::Font ^ font, bool focused, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string checkBoxText, System.Drawing.Font font, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string? checkBoxText, System.Drawing.Font? font, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Drawing.Rectangle * string * System.Drawing.Font * bool * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, textBounds As Rectangle, checkBoxText As String, font As Font, focused As Boolean, state As CheckBoxState)

Parameter

g
Graphics

Die zum Zeichnen des Kontrollkästchens verwendete Graphics.

glyphLocation
Point

Der Point, an dem das Symbol für das Kontrollkästchen gezeichnet werden soll.

textBounds
Rectangle

Das Rectangle, in dem der checkBoxText gezeichnet werden soll.

checkBoxText
String

Die String, die mit dem Kontrollkästchen gezeichnet werden soll.

font
Font

Der Font, der auf die checkBoxText angewendet werden soll.

focused
Boolean

true, um ein Fokusrechteck zu zeichnen, andernfalls false.

state
CheckBoxState

Einer der CheckBoxState-Werte, der den visuellen Zustand des Kontrollkästchens angibt.

Hinweise

Wenn visuelle Formatvorlagen im Betriebssystem aktiviert sind und visuelle Formatvorlagen auf die aktuelle Anwendung angewendet werden, zeichnet diese Methode das Kontrollkästchen mit der aktuellen visuellen Formatvorlage. Andernfalls wird das Kontrollkästchen mit dem klassischen Windows-Format gezeichnet.

Gilt für

DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Boolean, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position, mit dem angegebenen Text und der angegebenen Textformatierung und mit einem optionalen Fokusrechteck.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Drawing::Rectangle textBounds, System::String ^ checkBoxText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, bool focused, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string checkBoxText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string? checkBoxText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.TextFormatFlags * bool * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, textBounds As Rectangle, checkBoxText As String, font As Font, flags As TextFormatFlags, focused As Boolean, state As CheckBoxState)

Parameter

g
Graphics

Die zum Zeichnen des Kontrollkästchens verwendete Graphics.

glyphLocation
Point

Der Point, an dem das Symbol für das Kontrollkästchen gezeichnet werden soll.

textBounds
Rectangle

Das Rectangle, in dem der checkBoxText gezeichnet werden soll.

checkBoxText
String

Die String, die mit dem Kontrollkästchen gezeichnet werden soll.

font
Font

Der Font, der auf die checkBoxText angewendet werden soll.

flags
TextFormatFlags

Eine bitweise Kombination der TextFormatFlags-Werte.

focused
Boolean

true, um ein Fokusrechteck zu zeichnen, andernfalls false.

state
CheckBoxState

Einer der CheckBoxState-Werte, der den visuellen Zustand des Kontrollkästchens angibt.

Beispiele

Im folgenden Codebeispiel wird die DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Boolean, CheckBoxState) Methode in der Methode eines benutzerdefinierten Steuerelements OnPaint verwendet, um ein Kontrollkästchen im Zustand zu zeichnen, der durch die Position des Mauszeigers bestimmt wird. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die CheckBoxRenderer Klasse bereitgestellt wird.

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

    CheckBoxRenderer::DrawCheckBox(e->Graphics,
        ClientRectangle.Location, this->getTextRectangle(), this->Text,
        this->Font, TextFormatFlags::HorizontalCenter,
        clicked, state);
}


// Draw the check box in the checked or unchecked state, alternately.
virtual void OnMouseDown(MouseEventArgs ^e) override
{
    Control::OnMouseDown(e);

    if (!clicked)
    {
        clicked = true;
        this->Text = "Clicked!";
        state = CheckBoxState::CheckedPressed;
        Invalidate();
    }
    else
    {
        clicked = false;
        this->Text = "Click here";
        state = CheckBoxState::UncheckedNormal;
        Invalidate();
    }
}
// Draw the check box in the current state.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    CheckBoxRenderer.DrawCheckBox(e.Graphics,
        ClientRectangle.Location, TextRectangle, this.Text,
        this.Font, TextFormatFlags.HorizontalCenter,
        clicked, state);
}

// Draw the check box in the checked or unchecked state, alternately.
protected override void OnMouseDown(MouseEventArgs e)
{
    base.OnMouseDown(e);

    if (!clicked)
    {
        clicked = true;
        this.Text = "Clicked!";
        state = CheckBoxState.CheckedPressed;
        Invalidate();
    }
    else
    {
        clicked = false;
        this.Text = "Click here";
        state = CheckBoxState.UncheckedNormal;
        Invalidate();
    }
}
' Draw the check box in the current state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)
    CheckBoxRenderer.DrawCheckBox(e.Graphics, _
        Me.ClientRectangle.Location, TextRectangle, Me.Text, _
        Me.Font, TextFormatFlags.HorizontalCenter, _
        clicked, state)
End Sub

' Draw the check box in the checked or unchecked state, alternately.
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
    MyBase.OnMouseDown(e)
    If Not clicked Then
        With Me
            .clicked = True
            .Text = "Clicked!"
            .state = CheckBoxState.CheckedPressed
        End With
        Invalidate()
    Else
        With Me
            .clicked = False
            .Text = "Click here"
            .state = CheckBoxState.UncheckedNormal
        End With
        Invalidate()
    End If
End Sub

Hinweise

Wenn visuelle Formatvorlagen im Betriebssystem aktiviert sind und visuelle Formatvorlagen auf die aktuelle Anwendung angewendet werden, zeichnet diese Methode das Kontrollkästchen mit der aktuellen visuellen Formatvorlage. Andernfalls wird das Kontrollkästchen mit dem klassischen Windows-Format gezeichnet.

Gilt für

DrawCheckBox(Graphics, Point, Rectangle, String, Font, Image, Rectangle, Boolean, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position, mit dem angegebenen Text und Bild und mit einem optionalen Fokusrechteck.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Drawing::Rectangle textBounds, System::String ^ checkBoxText, System::Drawing::Font ^ font, System::Drawing::Image ^ image, System::Drawing::Rectangle imageBounds, bool focused, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string checkBoxText, System.Drawing.Font font, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string? checkBoxText, System.Drawing.Font? font, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Drawing.Rectangle * string * System.Drawing.Font * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, textBounds As Rectangle, checkBoxText As String, font As Font, image As Image, imageBounds As Rectangle, focused As Boolean, state As CheckBoxState)

Parameter

g
Graphics

Die zum Zeichnen des Kontrollkästchens verwendete Graphics.

glyphLocation
Point

Der Point, an dem das Symbol für das Kontrollkästchen gezeichnet werden soll.

textBounds
Rectangle

Das Rectangle, in dem der checkBoxText gezeichnet werden soll.

checkBoxText
String

Die String, die mit dem Kontrollkästchen gezeichnet werden soll.

font
Font

Der Font, der auf die checkBoxText angewendet werden soll.

image
Image

Die Image, die mit dem Kontrollkästchen gezeichnet werden soll.

imageBounds
Rectangle

Das Rectangle, das die Dimensionen von image darstellt.

focused
Boolean

true, um ein Fokusrechteck zu zeichnen, andernfalls false.

state
CheckBoxState

Einer der CheckBoxState-Werte, der den visuellen Zustand des Kontrollkästchens angibt.

Hinweise

Wenn visuelle Formatvorlagen im Betriebssystem aktiviert sind und visuelle Formatvorlagen auf die aktuelle Anwendung angewendet werden, zeichnet diese Methode das Kontrollkästchen mit der aktuellen visuellen Formatvorlage. Andernfalls wird das Kontrollkästchen mit dem klassischen Windows-Format gezeichnet.

Gilt für

DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, CheckBoxState)

Zeichnet ein Kontrollkästchen-Steuerelement im angegebenen Zustand und an der angegebenen Position, mit dem angegebenen Text, der angegebenen Textformatierung und dem angegebenen Bild sowie mit einem optionalen Fokusrechteck.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Drawing::Rectangle textBounds, System::String ^ checkBoxText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, System::Drawing::Image ^ image, System::Drawing::Rectangle imageBounds, bool focused, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string checkBoxText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string? checkBoxText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.TextFormatFlags * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, textBounds As Rectangle, checkBoxText As String, font As Font, flags As TextFormatFlags, image As Image, imageBounds As Rectangle, focused As Boolean, state As CheckBoxState)

Parameter

g
Graphics

Die zum Zeichnen des Kontrollkästchens verwendete Graphics.

glyphLocation
Point

Der Point, an dem das Symbol für das Kontrollkästchen gezeichnet werden soll.

textBounds
Rectangle

Das Rectangle, in dem der checkBoxText gezeichnet werden soll.

checkBoxText
String

Die String, die mit dem Kontrollkästchen gezeichnet werden soll.

font
Font

Der Font, der auf die checkBoxText angewendet werden soll.

flags
TextFormatFlags

Eine bitweise Kombination der TextFormatFlags-Werte.

image
Image

Die Image, die mit dem Kontrollkästchen gezeichnet werden soll.

imageBounds
Rectangle

Das Rectangle, das die Dimensionen von image darstellt.

focused
Boolean

true, um ein Fokusrechteck zu zeichnen, andernfalls false.

state
CheckBoxState

Einer der CheckBoxState-Werte, der den visuellen Zustand des Kontrollkästchens angibt.

Hinweise

Wenn visuelle Formatvorlagen im Betriebssystem aktiviert sind und visuelle Formatvorlagen auf die aktuelle Anwendung angewendet werden, zeichnet diese Methode das Kontrollkästchen mit der aktuellen visuellen Formatvorlage. Andernfalls wird das Kontrollkästchen mit dem klassischen Windows-Format gezeichnet.

Gilt für