VisualStyleRenderer.DrawText Method

Definition

Draws text in the specified bounds.

Overloads

DrawText(IDeviceContext, Rectangle, String, Boolean, TextFormatFlags)

Draws text in the specified bounding rectangle with the option of displaying disabled text and applying other text formatting.

DrawText(IDeviceContext, Rectangle, String)

Draws text in the specified bounds using default formatting.

DrawText(IDeviceContext, Rectangle, String, Boolean)

Draws text in the specified bounds with the option of displaying disabled text.

DrawText(IDeviceContext, Rectangle, String, Boolean, TextFormatFlags)

Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs

Draws text in the specified bounding rectangle with the option of displaying disabled text and applying other text formatting.

C#
public void DrawText(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, string textToDraw, bool drawDisabled, System.Windows.Forms.TextFormatFlags flags);
C#
public void DrawText(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, string? textToDraw, bool drawDisabled, System.Windows.Forms.TextFormatFlags flags);

Parameters

dc
IDeviceContext

The IDeviceContext used to draw the text.

bounds
Rectangle

A Rectangle in which to draw the text.

textToDraw
String

The text to draw.

drawDisabled
Boolean

true to draw grayed-out text; otherwise, false.

flags
TextFormatFlags

A bitwise combination of the TextFormatFlags values.

Exceptions

dc is null.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

DrawText(IDeviceContext, Rectangle, String)

Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs

Draws text in the specified bounds using default formatting.

C#
public void DrawText(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, string textToDraw);
C#
public void DrawText(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, string? textToDraw);

Parameters

dc
IDeviceContext

The IDeviceContext used to draw the text.

bounds
Rectangle

A Rectangle in which to draw the text.

textToDraw
String

The text to draw.

Exceptions

dc is null.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

DrawText(IDeviceContext, Rectangle, String, Boolean)

Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs

Draws text in the specified bounds with the option of displaying disabled text.

C#
public void DrawText(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, string textToDraw, bool drawDisabled);
C#
public void DrawText(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, string? textToDraw, bool drawDisabled);

Parameters

dc
IDeviceContext

The IDeviceContext used to draw the text.

bounds
Rectangle

A Rectangle in which to draw the text.

textToDraw
String

The text to draw.

drawDisabled
Boolean

true to draw grayed-out text; otherwise, false.

Exceptions

dc is null.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10