ComboBoxRenderer.DrawTextBox 메서드

정의

운영 체제의 현재 비주얼 스타일을 사용하여 텍스트 상자를 그립니다.

오버로드

DrawTextBox(Graphics, Rectangle, ComboBoxState)

지정된 상태와 범위로 텍스트 상자를 그립니다.

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

지정된 텍스트를 사용하여 지정된 상태와 범위로 텍스트 상자를 그립니다.

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

지정된 텍스트와 텍스트 범위를 사용하여 지정된 상태와 범위로 텍스트 상자를 그립니다.

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

지정된 텍스트와 텍스트 형식을 사용하여 지정된 상태와 범위로 텍스트 상자를 그립니다.

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

지정된 텍스트, 텍스트 형식 및 텍스트 범위를 사용하여 지정된 상태와 범위로 텍스트 상자를 그립니다.

DrawTextBox(Graphics, Rectangle, ComboBoxState)

지정된 상태와 범위로 텍스트 상자를 그립니다.

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)

매개 변수

g
Graphics

텍스트 상자를 그리는 데 사용되는 Graphics입니다.

bounds
Rectangle

텍스트 상자의 범위를 지정하는 Rectangle입니다.

state
ComboBoxState

텍스트 상자의 표시 상태를 지정하는 ComboBoxState 값 중 하나입니다.

예외

운영 체제에서 비주얼 스타일을 지원하지 않는 경우

또는

운영 체제에서 사용자가 비주얼 스타일을 사용하지 않도록 설정한 경우

또는

비주얼 스타일이 애플리케이션 창의 클라이언트 영역에 적용되지 않은 경우

설명

이 메서드를 호출 하기 전에 있는지 확인 해야 합니다 IsSupported 속성이 반환 true합니다.

적용 대상

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

지정된 텍스트를 사용하여 지정된 상태와 범위로 텍스트 상자를 그립니다.

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)

매개 변수

g
Graphics

텍스트 상자를 그리는 데 사용되는 Graphics입니다.

bounds
Rectangle

텍스트 상자의 범위를 지정하는 Rectangle입니다.

comboBoxText
String

텍스트 상자에 그릴 String입니다.

font
Font

comboBoxText에 적용할 Font입니다.

state
ComboBoxState

텍스트 상자의 표시 상태를 지정하는 ComboBoxState 값 중 하나입니다.

예외

운영 체제에서 비주얼 스타일을 지원하지 않는 경우

또는

운영 체제에서 사용자가 비주얼 스타일을 사용하지 않도록 설정한 경우

또는

비주얼 스타일이 애플리케이션 창의 클라이언트 영역에 적용되지 않은 경우

설명

이 메서드를 호출 하기 전에 있는지 확인 해야 합니다 IsSupported 속성이 반환 true합니다.

적용 대상

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

지정된 텍스트와 텍스트 범위를 사용하여 지정된 상태와 범위로 텍스트 상자를 그립니다.

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)

매개 변수

g
Graphics

텍스트 상자를 그리는 데 사용되는 Graphics입니다.

bounds
Rectangle

텍스트 상자의 범위를 지정하는 Rectangle입니다.

comboBoxText
String

텍스트 상자에 그릴 String입니다.

font
Font

comboBoxText에 적용할 Font입니다.

textBounds
Rectangle

comboBoxText를 그릴 범위를 지정하는 Rectangle입니다.

state
ComboBoxState

텍스트 상자의 표시 상태를 지정하는 ComboBoxState 값 중 하나입니다.

예외

운영 체제에서 비주얼 스타일을 지원하지 않는 경우

또는

운영 체제에서 사용자가 비주얼 스타일을 사용하지 않도록 설정한 경우

또는

비주얼 스타일이 애플리케이션 창의 클라이언트 영역에 적용되지 않은 경우

예제

다음 코드 예제에서는 합니다 DrawTextBox(Graphics, Rectangle, String, Font, ComboBoxState) 메서드는 사용자 지정 컨트롤의 OnPaint 텍스트 상자를 그리는 방법입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ComboBoxRenderer 클래스입니다.

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

설명

이 메서드를 호출 하기 전에 있는지 확인 해야 합니다 IsSupported 속성이 반환 true합니다.

적용 대상

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

지정된 텍스트와 텍스트 형식을 사용하여 지정된 상태와 범위로 텍스트 상자를 그립니다.

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)

매개 변수

g
Graphics

텍스트 상자를 그리는 데 사용되는 Graphics입니다.

bounds
Rectangle

텍스트 상자의 범위를 지정하는 Rectangle입니다.

comboBoxText
String

텍스트 상자에 그릴 String입니다.

font
Font

comboBoxText에 적용할 Font입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

state
ComboBoxState

텍스트 상자의 표시 상태를 지정하는 ComboBoxState 값 중 하나입니다.

예외

운영 체제에서 비주얼 스타일을 지원하지 않는 경우

또는

운영 체제에서 사용자가 비주얼 스타일을 사용하지 않도록 설정한 경우

또는

비주얼 스타일이 애플리케이션 창의 클라이언트 영역에 적용되지 않은 경우

설명

이 메서드를 호출 하기 전에 있는지 확인 해야 합니다 IsSupported 속성이 반환 true합니다.

적용 대상

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

지정된 텍스트, 텍스트 형식 및 텍스트 범위를 사용하여 지정된 상태와 범위로 텍스트 상자를 그립니다.

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)

매개 변수

g
Graphics

텍스트 상자를 그리는 데 사용되는 Graphics입니다.

bounds
Rectangle

텍스트 상자의 범위를 지정하는 Rectangle입니다.

comboBoxText
String

텍스트 상자에 그릴 String입니다.

font
Font

comboBoxText에 적용할 Font입니다.

textBounds
Rectangle

comboBoxText를 그릴 범위를 지정하는 Rectangle입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

state
ComboBoxState

텍스트 상자의 표시 상태를 지정하는 ComboBoxState 값 중 하나입니다.

예외

운영 체제에서 비주얼 스타일을 지원하지 않는 경우

또는

운영 체제에서 사용자가 비주얼 스타일을 사용하지 않도록 설정한 경우

또는

비주얼 스타일이 애플리케이션 창의 클라이언트 영역에 적용되지 않은 경우

설명

이 메서드를 호출 하기 전에 있는지 확인 해야 합니다 IsSupported 속성이 반환 true합니다.

적용 대상