Partager via


ComboBoxRenderer.DrawTextBox Méthode

Définition

Dessine une zone de texte avec le style visuel actuel du système d’exploitation.

Surcharges

Nom Description
DrawTextBox(Graphics, Rectangle, ComboBoxState)

Dessine une zone de texte dans l’état et les limites spécifiés.

DrawTextBox(Graphics, Rectangle, String, Font, ComboBoxState)

Dessine une zone de texte dans l’état et les limites spécifiés, avec le texte spécifié.

DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, ComboBoxState)

Dessine une zone de texte dans l’état et les limites spécifiés, avec les limites de texte et de texte spécifiées.

DrawTextBox(Graphics, Rectangle, String, Font, TextFormatFlags, ComboBoxState)

Dessine une zone de texte dans l’état et les limites spécifiés, avec le texte et la mise en forme de texte spécifiés.

DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, ComboBoxState)

Dessine une zone de texte dans l’état et les limites spécifiés, avec le texte, la mise en forme du texte et les limites de texte spécifiées.

DrawTextBox(Graphics, Rectangle, ComboBoxState)

Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs

Dessine une zone de texte dans l’état et les limites spécifiés.

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

Paramètres

g
Graphics

Utilisé Graphics pour dessiner la zone de texte.

bounds
Rectangle

Qui Rectangle spécifie les limites de la zone de texte.

state
ComboBoxState

Une des ComboBoxState valeurs qui spécifie l’état visuel de la zone de texte.

Exceptions

Le système d’exploitation ne prend pas en charge les styles visuels.

- ou -

Les styles visuels sont désactivés par l’utilisateur dans le système d’exploitation.

- ou -

Les styles visuels ne sont pas appliqués à la zone cliente des fenêtres d’application.

Remarques

Avant d’appeler cette méthode, vous devez vérifier que la IsSupported propriété retourne true.

S’applique à

DrawTextBox(Graphics, Rectangle, String, Font, ComboBoxState)

Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs

Dessine une zone de texte dans l’état et les limites spécifiés, avec le texte spécifié.

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

Paramètres

g
Graphics

Utilisé Graphics pour dessiner la zone de texte.

bounds
Rectangle

Qui Rectangle spécifie les limites de la zone de texte.

comboBoxText
String

Dessin String dans la zone de texte.

font
Font

À Font appliquer à comboBoxText.

state
ComboBoxState

Une des ComboBoxState valeurs qui spécifie l’état visuel de la zone de texte.

Exceptions

Le système d’exploitation ne prend pas en charge les styles visuels.

- ou -

Les styles visuels sont désactivés par l’utilisateur dans le système d’exploitation.

- ou -

Les styles visuels ne sont pas appliqués à la zone cliente des fenêtres d’application.

Remarques

Avant d’appeler cette méthode, vous devez vérifier que la IsSupported propriété retourne true.

S’applique à

DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, ComboBoxState)

Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs

Dessine une zone de texte dans l’état et les limites spécifiés, avec les limites de texte et de texte spécifiées.

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

Paramètres

g
Graphics

Utilisé Graphics pour dessiner la zone de texte.

bounds
Rectangle

Qui Rectangle spécifie les limites de la zone de texte.

comboBoxText
String

Dessin String dans la zone de texte.

font
Font

À Font appliquer à comboBoxText.

textBounds
Rectangle

Qui Rectangle spécifie les limites dans lesquelles dessiner comboBoxText.

state
ComboBoxState

Une des ComboBoxState valeurs qui spécifie l’état visuel de la zone de texte.

Exceptions

Le système d’exploitation ne prend pas en charge les styles visuels.

- ou -

Les styles visuels sont désactivés par l’utilisateur dans le système d’exploitation.

- ou -

Les styles visuels ne sont pas appliqués à la zone cliente des fenêtres d’application.

Exemples

L’exemple de code suivant utilise la méthode dans la DrawTextBox(Graphics, Rectangle, String, Font, ComboBoxState) méthode d’un contrôle personnalisé pour dessiner une zone de OnPaint texte. Cet exemple de code fait partie d’un exemple plus grand fourni pour la ComboBoxRenderer classe.

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

        if (!ComboBoxRenderer::IsSupported)
        {
            this->Parent->Text = "Visual Styles Disabled";
            return;
        }

        this->Parent->Text = "CustomComboBox Enabled";

        // Always draw the main text box and drop down arrow in their
        // current states
        ComboBoxRenderer::DrawTextBox(e->Graphics, topTextBoxRectangle,
            this->Text, this->Font, textBoxState);
        ComboBoxRenderer::DrawDropDownButton(e->Graphics, arrowRectangle,
            arrowState);

        // Only draw the bottom text box if the arrow has been clicked
        if (isActivated)
        {
            ComboBoxRenderer::DrawTextBox(e->Graphics,
                bottomTextBoxRectangle, bottomText, this->Font,
                textBoxState);
        }
    }

protected:
    virtual void OnMouseDown(MouseEventArgs^ e) override 
    {
        Control::OnMouseDown(e);

        // Check whether the user clicked the arrow.
        if (arrowRectangle.Contains(e->Location) &&
            ComboBoxRenderer::IsSupported)
        {
            // Draw the arrow in the pressed state.
            arrowState = ComboBoxState::Pressed;

            // The user has activated the combo box.
            if (!isActivated)
            {
                this->Text = "Clicked!";
                textBoxState = ComboBoxState::Pressed;
                isActivated = true;
            }

            // The user has deactivated the combo box.
            else
            {
                this->Text = "Click here";
                textBoxState = ComboBoxState::Normal;
                isActivated = false;
            }

            // Redraw the control.
            Invalidate();
        }
    }
// Draw the combo box in the current state.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    if (!ComboBoxRenderer.IsSupported)
    {
        this.Parent.Text = "Visual Styles Disabled";
        return;
    }

    this.Parent.Text = "CustomComboBox Enabled";

    // Always draw the main text box and drop down arrow in their 
    // current states
    ComboBoxRenderer.DrawTextBox(e.Graphics, topTextBoxRectangle,
        this.Text, this.Font, textBoxState);
    ComboBoxRenderer.DrawDropDownButton(e.Graphics, arrowRectangle,
        arrowState);

    // Only draw the bottom text box if the arrow has been clicked
    if (isActivated)
    {
        ComboBoxRenderer.DrawTextBox(e.Graphics,
            bottomTextBoxRectangle, bottomText, this.Font,
            textBoxState);
    }
}

protected override void OnMouseDown(MouseEventArgs e)
{
    base.OnMouseDown(e);

    // Check whether the user clicked the arrow.
    if (arrowRectangle.Contains(e.Location) &&
        ComboBoxRenderer.IsSupported)
    {
        // Draw the arrow in the pressed state.
        arrowState = ComboBoxState.Pressed;

        // The user has activated the combo box.
        if (!isActivated)
        {
            this.Text = "Clicked!";
            textBoxState = ComboBoxState.Pressed;
            isActivated = true;
        }

        // The user has deactivated the combo box.
        else
        {
            this.Text = "Click here";
            textBoxState = ComboBoxState.Normal;
            isActivated = false;
        }

        // Redraw the control.
        Invalidate();
    }
}
' Draw the combo box in the current state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    If Not ComboBoxRenderer.IsSupported Then
        Me.Parent.Text = "Visual Styles	Disabled"
        Return
    End If

    Me.Parent.Text = "CustomComboBox Enabled"

    ' Always draw the main text box and drop down arrow in their 
    ' current states.
    ComboBoxRenderer.DrawTextBox(e.Graphics, topTextBoxRectangle, _
        Me.Text, Me.Font, textBoxState)
    ComboBoxRenderer.DrawDropDownButton(e.Graphics, arrowRectangle, _
        arrowState)

    ' Only draw the bottom text box if the arrow has been clicked.
    If isActivated Then
        ComboBoxRenderer.DrawTextBox(e.Graphics, _
            bottomTextBoxRectangle, bottomText, Me.Font, textBoxState)
    End If
End Sub

Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
    MyBase.OnMouseDown(e)

    ' Check whether the user clicked the arrow.
    If arrowRectangle.Contains(e.Location) And _
        ComboBoxRenderer.IsSupported Then

        ' Draw the arrow in the pressed state.
        arrowState = ComboBoxState.Pressed

        ' The user has activated the combo box.
        If Not isActivated Then
            Me.Text = "Clicked!"
            textBoxState = ComboBoxState.Pressed
            isActivated = True

        ' The user has deactivated the combo box.
        Else
            Me.Text = "Click here"
            textBoxState = ComboBoxState.Normal
            isActivated = False
        End If

        ' Redraw the control.
        Invalidate()
    End If
End Sub

Remarques

Avant d’appeler cette méthode, vous devez vérifier que la IsSupported propriété retourne true.

S’applique à

DrawTextBox(Graphics, Rectangle, String, Font, TextFormatFlags, ComboBoxState)

Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs

Dessine une zone de texte dans l’état et les limites spécifiés, avec le texte et la mise en forme de texte spécifiés.

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

Paramètres

g
Graphics

Utilisé Graphics pour dessiner la zone de texte.

bounds
Rectangle

Qui Rectangle spécifie les limites de la zone de texte.

comboBoxText
String

Dessin String dans la zone de texte.

font
Font

À Font appliquer à comboBoxText.

flags
TextFormatFlags

Combinaison au niveau du bit des TextFormatFlags valeurs.

state
ComboBoxState

Une des ComboBoxState valeurs qui spécifie l’état visuel de la zone de texte.

Exceptions

Le système d’exploitation ne prend pas en charge les styles visuels.

- ou -

Les styles visuels sont désactivés par l’utilisateur dans le système d’exploitation.

- ou -

Les styles visuels ne sont pas appliqués à la zone cliente des fenêtres d’application.

Remarques

Avant d’appeler cette méthode, vous devez vérifier que la IsSupported propriété retourne true.

S’applique à

DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, ComboBoxState)

Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs
Source:
ComboBoxRenderer.cs

Dessine une zone de texte dans l’état et les limites spécifiés, avec le texte, la mise en forme du texte et les limites de texte spécifiées.

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

Paramètres

g
Graphics

Utilisé Graphics pour dessiner la zone de texte.

bounds
Rectangle

Qui Rectangle spécifie les limites de la zone de texte.

comboBoxText
String

Dessin String dans la zone de texte.

font
Font

À Font appliquer à comboBoxText.

textBounds
Rectangle

Qui Rectangle spécifie les limites dans lesquelles dessiner comboBoxText.

flags
TextFormatFlags

Combinaison au niveau du bit des TextFormatFlags valeurs.

state
ComboBoxState

Une des ComboBoxState valeurs qui spécifie l’état visuel de la zone de texte.

Exceptions

Le système d’exploitation ne prend pas en charge les styles visuels.

- ou -

Les styles visuels sont désactivés par l’utilisateur dans le système d’exploitation.

- ou -

Les styles visuels ne sont pas appliqués à la zone cliente des fenêtres d’application.

Remarques

Avant d’appeler cette méthode, vous devez vérifier que la IsSupported propriété retourne true.

S’applique à