ComboBoxRenderer.DrawTextBox Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee tekent u een tekstvak met de huidige visuele stijl van het besturingssysteem.
Overloads
| Name | Description |
|---|---|
| DrawTextBox(Graphics, Rectangle, ComboBoxState) |
Hiermee tekent u een tekstvak in de opgegeven status en grenzen. |
| DrawTextBox(Graphics, Rectangle, String, Font, ComboBoxState) |
Hiermee tekent u een tekstvak in de opgegeven status en grenzen, met de opgegeven tekst. |
| DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, ComboBoxState) |
Hiermee tekent u een tekstvak met de opgegeven status en grenzen, met de opgegeven tekst- en tekstgrenzen. |
| DrawTextBox(Graphics, Rectangle, String, Font, TextFormatFlags, ComboBoxState) |
Hiermee tekent u een tekstvak in de opgegeven status en grenzen, met de opgegeven tekst- en tekstopmaak. |
| DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, ComboBoxState) |
Hiermee tekent u een tekstvak met de opgegeven status en grenzen, met de opgegeven tekst, tekstopmaak en tekstgrenzen. |
DrawTextBox(Graphics, Rectangle, ComboBoxState)
Hiermee tekent u een tekstvak in de opgegeven status en grenzen.
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)
Parameters
- state
- ComboBoxState
Een van de ComboBoxState waarden waarmee de visuele status van het tekstvak wordt opgegeven.
Uitzonderingen
Het besturingssysteem biedt geen ondersteuning voor visuele stijlen.
– of –
Visuele stijlen worden uitgeschakeld door de gebruiker in het besturingssysteem.
– of –
Visuele stijlen worden niet toegepast op het clientgebied van toepassingsvensters.
Opmerkingen
Voordat u deze methode aanroepttrue, moet u controleren of de IsSupported eigenschap wordt geretourneerd.
Van toepassing op
DrawTextBox(Graphics, Rectangle, String, Font, ComboBoxState)
Hiermee tekent u een tekstvak in de opgegeven status en grenzen, met de opgegeven tekst.
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);
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)
Parameters
- state
- ComboBoxState
Een van de ComboBoxState waarden waarmee de visuele status van het tekstvak wordt opgegeven.
Uitzonderingen
Het besturingssysteem biedt geen ondersteuning voor visuele stijlen.
– of –
Visuele stijlen worden uitgeschakeld door de gebruiker in het besturingssysteem.
– of –
Visuele stijlen worden niet toegepast op het clientgebied van toepassingsvensters.
Opmerkingen
Voordat u deze methode aanroepttrue, moet u controleren of de IsSupported eigenschap wordt geretourneerd.
Van toepassing op
DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, ComboBoxState)
Hiermee tekent u een tekstvak met de opgegeven status en grenzen, met de opgegeven tekst- en tekstgrenzen.
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);
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)
Parameters
- textBounds
- Rectangle
Hiermee Rectangle geeft u de grenzen aan waarin moet worden getekend comboBoxText.
- state
- ComboBoxState
Een van de ComboBoxState waarden waarmee de visuele status van het tekstvak wordt opgegeven.
Uitzonderingen
Het besturingssysteem biedt geen ondersteuning voor visuele stijlen.
– of –
Visuele stijlen worden uitgeschakeld door de gebruiker in het besturingssysteem.
– of –
Visuele stijlen worden niet toegepast op het clientgebied van toepassingsvensters.
Voorbeelden
In het volgende codevoorbeeld wordt de methode in de DrawTextBox(Graphics, Rectangle, String, Font, ComboBoxState) methode van OnPaint een aangepast besturingselement gebruikt om een tekstvak te tekenen. Dit codevoorbeeld maakt deel uit van een groter voorbeeld voor de ComboBoxRenderer klasse.
// 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
Opmerkingen
Voordat u deze methode aanroepttrue, moet u controleren of de IsSupported eigenschap wordt geretourneerd.
Van toepassing op
DrawTextBox(Graphics, Rectangle, String, Font, TextFormatFlags, ComboBoxState)
Hiermee tekent u een tekstvak in de opgegeven status en grenzen, met de opgegeven tekst- en tekstopmaak.
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);
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)
Parameters
- flags
- TextFormatFlags
Een bitsgewijze combinatie van de TextFormatFlags waarden.
- state
- ComboBoxState
Een van de ComboBoxState waarden waarmee de visuele status van het tekstvak wordt opgegeven.
Uitzonderingen
Het besturingssysteem biedt geen ondersteuning voor visuele stijlen.
– of –
Visuele stijlen worden uitgeschakeld door de gebruiker in het besturingssysteem.
– of –
Visuele stijlen worden niet toegepast op het clientgebied van toepassingsvensters.
Opmerkingen
Voordat u deze methode aanroepttrue, moet u controleren of de IsSupported eigenschap wordt geretourneerd.
Van toepassing op
DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, ComboBoxState)
Hiermee tekent u een tekstvak met de opgegeven status en grenzen, met de opgegeven tekst, tekstopmaak en tekstgrenzen.
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);
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)
Parameters
- textBounds
- Rectangle
Hiermee Rectangle geeft u de grenzen aan waarin moet worden getekend comboBoxText.
- flags
- TextFormatFlags
Een bitsgewijze combinatie van de TextFormatFlags waarden.
- state
- ComboBoxState
Een van de ComboBoxState waarden waarmee de visuele status van het tekstvak wordt opgegeven.
Uitzonderingen
Het besturingssysteem biedt geen ondersteuning voor visuele stijlen.
– of –
Visuele stijlen worden uitgeschakeld door de gebruiker in het besturingssysteem.
– of –
Visuele stijlen worden niet toegepast op het clientgebied van toepassingsvensters.
Opmerkingen
Voordat u deze methode aanroepttrue, moet u controleren of de IsSupported eigenschap wordt geretourneerd.