ComboBoxRenderer.DrawTextBox Metod

Definition

Ritar en textruta med det aktuella visuella formatet för operativsystemet.

Överlagringar

Name Description
DrawTextBox(Graphics, Rectangle, ComboBoxState)

Ritar en textruta i det angivna tillståndet och gränserna.

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

Ritar en textruta i det angivna tillståndet och gränserna med den angivna texten.

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

Ritar en textruta i det angivna tillståndet och gränserna med angivna text- och textgräns.

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

Ritar en textruta i angivet tillstånd och gränser med angiven text- och textformatering.

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

Ritar en textruta i det angivna tillståndet och gränserna med angiven text, textformatering och textgräns.

DrawTextBox(Graphics, Rectangle, ComboBoxState)

Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs

Ritar en textruta i det angivna tillståndet och gränserna.

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)

Parametrar

g
Graphics

Används Graphics för att rita textrutan.

bounds
Rectangle

Som Rectangle anger gränserna för textrutan.

state
ComboBoxState

Ett av de ComboBoxState värden som anger det visuella tillståndet för textrutan.

Undantag

Operativsystemet stöder inte visuella format.

-eller-

Visuella format är inaktiverade av användaren i operativsystemet.

-eller-

Visuella format tillämpas inte på klientområdet i programfönster.

Kommentarer

Innan du anropar den här metoden bör du kontrollera att egenskapen IsSupported returnerar true.

Gäller för

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

Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs

Ritar en textruta i det angivna tillståndet och gränserna med den angivna texten.

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)

Parametrar

g
Graphics

Används Graphics för att rita textrutan.

bounds
Rectangle

Som Rectangle anger gränserna för textrutan.

comboBoxText
String

Att String rita i textrutan.

font
Font

Att Font gälla för comboBoxText.

state
ComboBoxState

Ett av de ComboBoxState värden som anger det visuella tillståndet för textrutan.

Undantag

Operativsystemet stöder inte visuella format.

-eller-

Visuella format är inaktiverade av användaren i operativsystemet.

-eller-

Visuella format tillämpas inte på klientområdet i programfönster.

Kommentarer

Innan du anropar den här metoden bör du kontrollera att egenskapen IsSupported returnerar true.

Gäller för

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

Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs

Ritar en textruta i det angivna tillståndet och gränserna med angivna text- och textgräns.

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)

Parametrar

g
Graphics

Används Graphics för att rita textrutan.

bounds
Rectangle

Som Rectangle anger gränserna för textrutan.

comboBoxText
String

Att String rita i textrutan.

font
Font

Att Font gälla för comboBoxText.

textBounds
Rectangle

Det Rectangle som anger de gränser som ska ritas comboBoxTexti .

state
ComboBoxState

Ett av de ComboBoxState värden som anger det visuella tillståndet för textrutan.

Undantag

Operativsystemet stöder inte visuella format.

-eller-

Visuella format är inaktiverade av användaren i operativsystemet.

-eller-

Visuella format tillämpas inte på klientområdet i programfönster.

Exempel

I följande kodexempel används DrawTextBox(Graphics, Rectangle, String, Font, ComboBoxState) metoden i en anpassad kontrollmetod OnPaint för att rita en textruta. Det här kodexemplet är en del av ett större exempel för ComboBoxRenderer klassen.

      // 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

Kommentarer

Innan du anropar den här metoden bör du kontrollera att egenskapen IsSupported returnerar true.

Gäller för

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

Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs

Ritar en textruta i angivet tillstånd och gränser med angiven text- och textformatering.

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)

Parametrar

g
Graphics

Används Graphics för att rita textrutan.

bounds
Rectangle

Som Rectangle anger gränserna för textrutan.

comboBoxText
String

Att String rita i textrutan.

font
Font

Att Font gälla för comboBoxText.

flags
TextFormatFlags

En bitvis kombination av TextFormatFlags värdena.

state
ComboBoxState

Ett av de ComboBoxState värden som anger det visuella tillståndet för textrutan.

Undantag

Operativsystemet stöder inte visuella format.

-eller-

Visuella format är inaktiverade av användaren i operativsystemet.

-eller-

Visuella format tillämpas inte på klientområdet i programfönster.

Kommentarer

Innan du anropar den här metoden bör du kontrollera att egenskapen IsSupported returnerar true.

Gäller för

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

Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs
Källa:
ComboBoxRenderer.cs

Ritar en textruta i det angivna tillståndet och gränserna med angiven text, textformatering och textgräns.

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)

Parametrar

g
Graphics

Används Graphics för att rita textrutan.

bounds
Rectangle

Som Rectangle anger gränserna för textrutan.

comboBoxText
String

Att String rita i textrutan.

font
Font

Att Font gälla för comboBoxText.

textBounds
Rectangle

Det Rectangle som anger de gränser som ska ritas comboBoxTexti .

flags
TextFormatFlags

En bitvis kombination av TextFormatFlags värdena.

state
ComboBoxState

Ett av de ComboBoxState värden som anger det visuella tillståndet för textrutan.

Undantag

Operativsystemet stöder inte visuella format.

-eller-

Visuella format är inaktiverade av användaren i operativsystemet.

-eller-

Visuella format tillämpas inte på klientområdet i programfönster.

Kommentarer

Innan du anropar den här metoden bör du kontrollera att egenskapen IsSupported returnerar true.

Gäller för