Bagikan melalui


ComboBoxRenderer.DrawTextBox Metode

Definisi

Menggambar kotak teks dengan gaya visual sistem operasi saat ini.

Overload

Nama Deskripsi
DrawTextBox(Graphics, Rectangle, ComboBoxState)

Menggambar kotak teks dalam status dan batas yang ditentukan.

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

Menggambar kotak teks dalam status dan batas yang ditentukan, dengan teks yang ditentukan.

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

Menggambar kotak teks dalam status dan batas yang ditentukan, dengan batas teks dan teks yang ditentukan.

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

Menggambar kotak teks dalam status dan batas yang ditentukan, dengan pemformatan teks dan teks yang ditentukan.

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

Menggambar kotak teks dalam status dan batas yang ditentukan, dengan teks, pemformatan teks, dan batas teks yang ditentukan.

DrawTextBox(Graphics, Rectangle, ComboBoxState)

Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs

Menggambar kotak teks dalam status dan batas yang ditentukan.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar kotak teks.

bounds
Rectangle

Rectangle yang menentukan batas kotak teks.

state
ComboBoxState

Salah ComboBoxState satu nilai yang menentukan status visual kotak teks.

Pengecualian

Sistem operasi tidak mendukung gaya visual.

-atau-

Gaya visual dinonaktifkan oleh pengguna dalam sistem operasi.

-atau-

Gaya visual tidak diterapkan ke area klien jendela aplikasi.

Keterangan

Sebelum memanggil metode ini, Anda harus memverifikasi bahwa IsSupported properti mengembalikan true.

Berlaku untuk

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

Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs

Menggambar kotak teks dalam status dan batas yang ditentukan, dengan teks yang ditentukan.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar kotak teks.

bounds
Rectangle

Rectangle yang menentukan batas kotak teks.

comboBoxText
String

untuk String menggambar dalam kotak teks.

font
Font

yang Font akan diterapkan ke comboBoxText.

state
ComboBoxState

Salah ComboBoxState satu nilai yang menentukan status visual kotak teks.

Pengecualian

Sistem operasi tidak mendukung gaya visual.

-atau-

Gaya visual dinonaktifkan oleh pengguna dalam sistem operasi.

-atau-

Gaya visual tidak diterapkan ke area klien jendela aplikasi.

Keterangan

Sebelum memanggil metode ini, Anda harus memverifikasi bahwa IsSupported properti mengembalikan true.

Berlaku untuk

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

Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs

Menggambar kotak teks dalam status dan batas yang ditentukan, dengan batas teks dan teks yang ditentukan.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar kotak teks.

bounds
Rectangle

Rectangle yang menentukan batas kotak teks.

comboBoxText
String

untuk String menggambar dalam kotak teks.

font
Font

yang Font akan diterapkan ke comboBoxText.

textBounds
Rectangle

Rectangle yang menentukan batas untuk menggambar comboBoxText.

state
ComboBoxState

Salah ComboBoxState satu nilai yang menentukan status visual kotak teks.

Pengecualian

Sistem operasi tidak mendukung gaya visual.

-atau-

Gaya visual dinonaktifkan oleh pengguna dalam sistem operasi.

-atau-

Gaya visual tidak diterapkan ke area klien jendela aplikasi.

Contoh

Contoh kode berikut menggunakan DrawTextBox(Graphics, Rectangle, String, Font, ComboBoxState) metode dalam metode kontrol OnPaint kustom untuk menggambar kotak teks. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk ComboBoxRenderer kelas .

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

Keterangan

Sebelum memanggil metode ini, Anda harus memverifikasi bahwa IsSupported properti mengembalikan true.

Berlaku untuk

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

Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs

Menggambar kotak teks dalam status dan batas yang ditentukan, dengan pemformatan teks dan teks yang ditentukan.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar kotak teks.

bounds
Rectangle

Rectangle yang menentukan batas kotak teks.

comboBoxText
String

untuk String menggambar dalam kotak teks.

font
Font

yang Font akan diterapkan ke comboBoxText.

flags
TextFormatFlags

Kombinasi bitwise dari TextFormatFlags nilai.

state
ComboBoxState

Salah ComboBoxState satu nilai yang menentukan status visual kotak teks.

Pengecualian

Sistem operasi tidak mendukung gaya visual.

-atau-

Gaya visual dinonaktifkan oleh pengguna dalam sistem operasi.

-atau-

Gaya visual tidak diterapkan ke area klien jendela aplikasi.

Keterangan

Sebelum memanggil metode ini, Anda harus memverifikasi bahwa IsSupported properti mengembalikan true.

Berlaku untuk

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

Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs
Sumber:
ComboBoxRenderer.cs

Menggambar kotak teks dalam status dan batas yang ditentukan, dengan teks, pemformatan teks, dan batas teks yang ditentukan.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar kotak teks.

bounds
Rectangle

Rectangle yang menentukan batas kotak teks.

comboBoxText
String

untuk String menggambar dalam kotak teks.

font
Font

yang Font akan diterapkan ke comboBoxText.

textBounds
Rectangle

Rectangle yang menentukan batas untuk menggambar comboBoxText.

flags
TextFormatFlags

Kombinasi bitwise dari TextFormatFlags nilai.

state
ComboBoxState

Salah ComboBoxState satu nilai yang menentukan status visual kotak teks.

Pengecualian

Sistem operasi tidak mendukung gaya visual.

-atau-

Gaya visual dinonaktifkan oleh pengguna dalam sistem operasi.

-atau-

Gaya visual tidak diterapkan ke area klien jendela aplikasi.

Keterangan

Sebelum memanggil metode ini, Anda harus memverifikasi bahwa IsSupported properti mengembalikan true.

Berlaku untuk