TextBoxRenderer.DrawTextBox Метод

Определение

Рисует текстовое поле с учетом текущего визуального стиля операционной системы.

Перегрузки

DrawTextBox(Graphics, Rectangle, TextBoxState)

Рисует текстовое поле в заданном состоянии и с заданными границами.

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

Рисует текстовое поле с заданным состоянием и текстом в установленных границах.

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

Рисует текстовое поле с заданным состоянием, текстом и границами текста в установленных границах.

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

Рисует текстовое поле с заданным состоянием в установленных границах, с заданным текстом и форматированием текста.

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

Рисует поле группы с заданным состоянием, в рамках заданных границ, с заданным текстом, границами и форматированием текста.

DrawTextBox(Graphics, Rectangle, TextBoxState)

Рисует текстовое поле в заданном состоянии и с заданными границами.

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

Параметры

g
Graphics

Объект Graphics используется для рисования текстового поля.

bounds
Rectangle

Rectangle указывает границы текстового поля.

state
TextBoxState

Одно из значений TextBoxState, с помощью которого задается внешний вид текстового поля.

Исключения

Эта операционная система не поддерживает стили оформления.

-или-

Стили оформления отключены пользователем этой операционной системы.

-или-

Визуальные стили не применяются к клиентской области окон приложений.

Комментарии

Перед вызовом этого метода необходимо убедиться, что IsSupported свойство возвращает trueзначение .

Применяется к

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

Рисует текстовое поле с заданным состоянием и текстом в установленных границах.

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

Параметры

g
Graphics

Объект Graphics используется для рисования текстового поля.

bounds
Rectangle

Rectangle указывает границы текстового поля.

textBoxText
String

String, которую необходимо нарисовать в текстовом поле.

font
Font

Снимок Font, применяемый к диапазонам textBoxText.

state
TextBoxState

Одно из значений TextBoxState, с помощью которого задается внешний вид текстового поля.

Исключения

Эта операционная система не поддерживает стили оформления.

-или-

Стили оформления отключены пользователем этой операционной системы.

-или-

Визуальные стили не применяются к клиентской области окон приложений.

Комментарии

Перед вызовом этого метода необходимо убедиться, что IsSupported свойство возвращает trueзначение .

Применяется к

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

Рисует текстовое поле с заданным состоянием, текстом и границами текста в установленных границах.

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

Параметры

g
Graphics

Объект Graphics используется для рисования текстового поля.

bounds
Rectangle

Rectangle указывает границы текстового поля.

textBoxText
String

String, которую необходимо нарисовать в текстовом поле.

font
Font

Снимок Font, применяемый к диапазонам textBoxText.

textBounds
Rectangle

Объект Rectangle, устанавливающий границы параметра textBoxText.

state
TextBoxState

Одно из значений TextBoxState, с помощью которого задается внешний вид текстового поля.

Исключения

Эта операционная система не поддерживает стили оформления.

-или-

Стили оформления отключены пользователем этой операционной системы.

-или-

Визуальные стили не применяются к клиентской области окон приложений.

Комментарии

Перед вызовом этого метода необходимо убедиться, что IsSupported свойство возвращает trueзначение .

Применяется к

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

Рисует текстовое поле с заданным состоянием в установленных границах, с заданным текстом и форматированием текста.

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

Параметры

g
Graphics

Объект Graphics используется для рисования текстового поля.

bounds
Rectangle

Rectangle указывает границы текстового поля.

textBoxText
String

String, которую необходимо нарисовать в текстовом поле.

font
Font

Снимок Font, применяемый к диапазонам textBoxText.

flags
TextFormatFlags

Поразрядное сочетание значений TextFormatFlags.

state
TextBoxState

Одно из значений TextBoxState, с помощью которого задается внешний вид текстового поля.

Исключения

Эта операционная система не поддерживает стили оформления.

-или-

Стили оформления отключены пользователем этой операционной системы.

-или-

Визуальные стили не применяются к клиентской области окон приложений.

Комментарии

Перед вызовом этого метода необходимо убедиться, что IsSupported свойство возвращает trueзначение .

Применяется к

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

Рисует поле группы с заданным состоянием, в рамках заданных границ, с заданным текстом, границами и форматированием текста.

public:
 static void DrawTextBox(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ textBoxText, System::Drawing::Font ^ font, System::Drawing::Rectangle textBounds, System::Windows::Forms::TextFormatFlags flags, System::Windows::Forms::VisualStyles::TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string textBoxText, System.Drawing.Font font, System.Drawing.Rectangle textBounds, System.Windows.Forms.TextFormatFlags flags, System.Windows.Forms.VisualStyles.TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? textBoxText, System.Drawing.Font? font, System.Drawing.Rectangle textBounds, System.Windows.Forms.TextFormatFlags flags, System.Windows.Forms.VisualStyles.TextBoxState 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.TextBoxState -> unit
Public Shared Sub DrawTextBox (g As Graphics, bounds As Rectangle, textBoxText As String, font As Font, textBounds As Rectangle, flags As TextFormatFlags, state As TextBoxState)

Параметры

g
Graphics

Объект Graphics используется для рисования текстового поля.

bounds
Rectangle

Rectangle указывает границы текстового поля.

textBoxText
String

String, которую необходимо нарисовать в текстовом поле.

font
Font

Снимок Font, применяемый к диапазонам textBoxText.

textBounds
Rectangle

Объект Rectangle, устанавливающий границы параметра textBoxText.

flags
TextFormatFlags

Поразрядное сочетание значений TextFormatFlags.

state
TextBoxState

Одно из значений TextBoxState, с помощью которого задается внешний вид текстового поля.

Исключения

Эта операционная система не поддерживает стили оформления.

-или-

Стили оформления отключены пользователем этой операционной системы.

-или-

Визуальные стили не применяются к клиентской области окон приложений.

Примеры

В следующем примере кода показано, как использовать DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, TextBoxState) метод в методе пользовательского OnPaint элемента управления для рисования текстового поля. Этот пример входит в состав более крупного примера использования класса TextBoxRenderer.

    // Use DrawText with the current TextFormatFlags.

protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        if (TextBoxRenderer::IsSupported)
        {
            TextBoxRenderer::DrawTextBox(e->Graphics, textBorder, this->Text,
                this->Font, textRectangle, textFlags, TextBoxState::Normal);

            this->Parent->Text = "CustomTextBox Enabled";
        }
        else
        {
            this->Parent->Text = "CustomTextBox Disabled";
        }
    }
// Use DrawText with the current TextFormatFlags.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    if (TextBoxRenderer.IsSupported)
    {
        TextBoxRenderer.DrawTextBox(e.Graphics, textBorder, this.Text,
            this.Font, textRectangle, textFlags, TextBoxState.Normal);

        this.Parent.Text = "CustomTextBox Enabled";
    }
    else
    {
        this.Parent.Text = "CustomTextBox Disabled";
    }
}
' Use DrawText with the current TextFormatFlags.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    If TextBoxRenderer.IsSupported Then
        TextBoxRenderer.DrawTextBox(e.Graphics, textBorder, Me.Text, _
            Me.Font, textRectangle, textFlags, TextBoxState.Normal)
        Me.Parent.Text = "CustomTextBox Enabled"
    Else
        Me.Parent.Text = "CustomTextBox Disabled"
    End If
End Sub

Комментарии

Перед вызовом этого метода необходимо убедиться, что IsSupported свойство возвращает trueзначение .

Применяется к