Бөлісу құралы:


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)

Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs

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

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)

Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs

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

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)

Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs

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

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)

Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs

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

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)

Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs
Исходный код:
TextBoxRenderer.cs

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

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.

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