TextRenderer.DrawText 메서드

정의

지정된 디바이스 컨텍스트, 색 및 글꼴을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

오버로드

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Point, Color)

지정된 디바이스 컨텍스트, 글꼴 및 색을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, String, Font, Rectangle, Color, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색, 배경색 및 서식 명령을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, String, Font, Point, Color, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색, 배경색 및 서식 명령을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Point, Color, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색, 배경색 및 서식 명령을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, String, Font, Rectangle, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색 및 서식 명령을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, String, Font, Rectangle, Color, Color)

지정된 디바이스 컨텍스트, 글꼴, 색 및 배경색을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, String, Font, Point, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색 및 서식 명령을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, String, Font, Point, Color, Color)

지정된 디바이스 컨텍스트, 글꼴, 색 및 배경색을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Rectangle, Color, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색, 배경색 및 서식 명령을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Rectangle, Color, Color)

지정된 디바이스 컨텍스트, 글꼴, 색 및 배경색을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Point, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색 및 서식 명령을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Point, Color, Color)

지정된 디바이스 컨텍스트, 글꼴, 색 및 배경색을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, String, Font, Rectangle, Color)

지정된 디바이스 컨텍스트, 글꼴 및 색을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, String, Font, Point, Color)

지정된 디바이스 컨텍스트, 글꼴 및 색을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Rectangle, Color)

지정된 디바이스 컨텍스트, 글꼴 및 색을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Rectangle, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색 및 서식 명령을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

설명

제공 하는 텍스트 렌더링을 TextRenderer 클래스는 GDI 텍스트 렌더링에 기반 하며 Windows Forms의 인쇄에 지원 되지 않습니다. 대신 사용 합니다 DrawString 의 메서드는 Graphics 클래스.

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Point, Color)

지정된 디바이스 컨텍스트, 글꼴 및 색을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, ReadOnlySpan<char> text, System::Drawing::Font ^ font, System::Drawing::Point pt, System::Drawing::Color foreColor);
public static void DrawText (System.Drawing.IDeviceContext dc, ReadOnlySpan<char> text, System.Drawing.Font font, System.Drawing.Point pt, System.Drawing.Color foreColor);
static member DrawText : System.Drawing.IDeviceContext * ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Point * System.Drawing.Color -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As ReadOnlySpan(Of Char), font As Font, pt As Point, foreColor As Color)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
ReadOnlySpan<Char>

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

pt
Point

그린 텍스트의 왼쪽 위 모퉁이를 나타내는 Point입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

예외

dc이(가) null인 경우

적용 대상

DrawText(IDeviceContext, String, Font, Rectangle, Color, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색, 배경색 및 서식 명령을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Rectangle bounds, System::Drawing::Color foreColor, System::Drawing::Color backColor, System::Windows::Forms::TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor, System.Drawing.Color backColor, System.Windows.Forms.TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, string? text, System.Drawing.Font? font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor, System.Drawing.Color backColor, System.Windows.Forms.TextFormatFlags flags);
static member DrawText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Rectangle * System.Drawing.Color * System.Drawing.Color * System.Windows.Forms.TextFormatFlags -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As String, font As Font, bounds As Rectangle, foreColor As Color, backColor As Color, flags As TextFormatFlags)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
String

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

bounds
Rectangle

텍스트의 범위를 나타내는 Rectangle입니다.

foreColor
Color

텍스트에 적용할 Color입니다.

backColor
Color

bounds가 나타내는 영역에 적용할 Color입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

예외

dc이(가) null인 경우

예제

다음 코드 예제에서는 DrawText 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행 하려면 호출을 Windows Form에 코드를 붙여넣은 RenderText8 폼의 Paint 이벤트 처리기를 전달 e 으로 PaintEventArgs입니다.

private void RenderText8(PaintEventArgs e)
{
    TextFormatFlags flags = TextFormatFlags.Bottom | TextFormatFlags.WordBreak;
    TextRenderer.DrawText(e.Graphics, "This is some text that will display on multiple lines.", this.Font,
        new Rectangle(10, 10, 100, 50), SystemColors.ControlText, SystemColors.ControlDark, flags);
}
Private Sub RenderText8(ByVal e As PaintEventArgs)
    Dim flags As TextFormatFlags = _
        TextFormatFlags.Bottom Or TextFormatFlags.WordBreak
    TextRenderer.DrawText(e.Graphics, _
        "This is some text that will display on multiple lines.", _
        Me.Font, New Rectangle(10, 10, 100, 50), _
        SystemColors.ControlText, SystemColors.ControlDark, flags)

End Sub

설명

backcolor 내의 영역으로 매개 변수가 적용 되는 bounds 매개 변수. 하는 경우 font, forecolor 또는 backcolornull 또는 Empty각각;는 DrawText 메서드는 글꼴 또는 색으로 지정 된 디바이스 컨텍스트에서 현재 선택 된 텍스트를 그리는 dc합니다. 하는 경우 forecolorTransparent, 텍스트를 가져오게 됩니다.

DrawText 매개 변수를 사용하는 TextFormatFlags 오버로드 중 하나를 사용하여 텍스트를 그리는 방법을 조작할 수 있습니다. 예를 들어, TextRenderer의 기본 동작은 걸친 모양의 문자를 표시하기 위해 그린 텍스트의 경계 사각형에 여백을 추가하는 것입니다. 이러한 추가 공간 없이 한 줄의 텍스트를 그려야 하는 경우 DrawTextMeasureText 매개 변수를 사용하는 SizeTextFormatFlags의 버전을 사용해야 합니다. 예제를 보려면 MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags)를 참조하세요.

제공 하는 텍스트 렌더링을 TextRenderer 클래스는 GDI 텍스트 렌더링에 기반 하며 Windows Forms의 인쇄에 지원 되지 않습니다. 대신 사용 합니다 DrawString 의 메서드는 Graphics 클래스.

합니다 TextRenderer 사용을 중지할 기존 탭을 확장할 수 있지만 그린된 텍스트에 탭 정지를 추가 하는 지원 하지 않습니다는 ExpandTabs 플래그입니다.

적용 대상

DrawText(IDeviceContext, String, Font, Point, Color, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색, 배경색 및 서식 명령을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Point pt, System::Drawing::Color foreColor, System::Drawing::Color backColor, System::Windows::Forms::TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Point pt, System.Drawing.Color foreColor, System.Drawing.Color backColor, System.Windows.Forms.TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, string? text, System.Drawing.Font? font, System.Drawing.Point pt, System.Drawing.Color foreColor, System.Drawing.Color backColor, System.Windows.Forms.TextFormatFlags flags);
static member DrawText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Point * System.Drawing.Color * System.Drawing.Color * System.Windows.Forms.TextFormatFlags -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As String, font As Font, pt As Point, foreColor As Color, backColor As Color, flags As TextFormatFlags)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
String

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

pt
Point

그린 텍스트의 왼쪽 위 모퉁이를 나타내는 Point입니다.

foreColor
Color

텍스트에 적용할 Color입니다.

backColor
Color

그린 텍스트의 배경 영역에 적용할 Color입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

예외

dc이(가) null인 경우

예제

다음 코드 예제에서는 DrawText 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행 하려면 호출을 Windows Form에 코드를 붙여넣은 RenderText7 폼의 Paint 이벤트 처리기를 전달 e 으로 PaintEventArgs입니다.

private void RenderText7(PaintEventArgs e)
{
    TextRenderer.DrawText(e.Graphics, "This is some text.", this.Font,
        new Point(10, 10), Color.White, Color.SteelBlue, TextFormatFlags.Default);
}
Private Sub RenderText7(ByVal e As PaintEventArgs)
    TextRenderer.DrawText(e.Graphics, "This is some text.", _
        Me.Font, New Point(10, 10), Color.White, Color.SteelBlue, _
        TextFormatFlags.Default)

End Sub

설명

backcolor 매개 변수가 적용 그린된 텍스트를 포함 하는 사각형 영역입니다. 경우 font 또는 forecolor 됩니다 null 또는 Empty각각; 합니다 DrawText 메서드 글꼴 또는 색으로 지정 된 디바이스 컨텍스트에서 현재 선택 된 텍스트를 그립니다 dc합니다. 하는 경우 forecolorTransparent, 텍스트를 가져오게 됩니다.

DrawText 매개 변수를 사용하는 TextFormatFlags 오버로드 중 하나를 사용하여 텍스트를 그리는 방법을 조작할 수 있습니다. 예를 들어, TextRenderer의 기본 동작은 걸친 모양의 문자를 표시하기 위해 그린 텍스트의 경계 사각형에 여백을 추가하는 것입니다. 이러한 추가 공간 없이 한 줄의 텍스트를 그려야 하는 경우 DrawTextMeasureText 매개 변수를 사용하는 SizeTextFormatFlags의 버전을 사용해야 합니다. 예제를 보려면 MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags)를 참조하세요.

제공 하는 텍스트 렌더링을 TextRenderer 클래스는 GDI 텍스트 렌더링에 기반 하며 Windows Forms의 인쇄에 지원 되지 않습니다. 대신 사용 합니다 DrawString 의 메서드는 Graphics 클래스.

합니다 TextRenderer 사용을 중지할 기존 탭을 확장할 수 있지만 그린된 텍스트에 탭 정지를 추가 하는 지원 하지 않습니다는 ExpandTabs 플래그입니다.

참고

합니다 DrawText 지정 하는 메서드를 Point 그려지는 텍스트의 왼쪽 위 모퉁이를 제대로 렌더링 되지 않는 Windows 2000에서. 애플리케이션 Windows 2000을 실행 하는 컴퓨터에서 사용 하기 위한, 하나를 사용 해야 하는 DrawText 지정 하는 메서드를 Rectangle 그려지는 텍스트의 범위에 대 한 합니다.

적용 대상

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Point, Color, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색, 배경색 및 서식 명령을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, ReadOnlySpan<char> text, System::Drawing::Font ^ font, System::Drawing::Point pt, System::Drawing::Color foreColor, System::Drawing::Color backColor, System::Windows::Forms::TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, ReadOnlySpan<char> text, System.Drawing.Font? font, System.Drawing.Point pt, System.Drawing.Color foreColor, System.Drawing.Color backColor, System.Windows.Forms.TextFormatFlags flags);
static member DrawText : System.Drawing.IDeviceContext * ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Point * System.Drawing.Color * System.Drawing.Color * System.Windows.Forms.TextFormatFlags -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As ReadOnlySpan(Of Char), font As Font, pt As Point, foreColor As Color, backColor As Color, flags As TextFormatFlags)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
ReadOnlySpan<Char>

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

pt
Point

그린 텍스트의 왼쪽 위 모퉁이를 나타내는 Point입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

backColor
Color

그린 텍스트의 배경 영역에 적용할 Color입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

예외

dc이(가) null인 경우.

적용 대상

DrawText(IDeviceContext, String, Font, Rectangle, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색 및 서식 명령을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Rectangle bounds, System::Drawing::Color foreColor, System::Windows::Forms::TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor, System.Windows.Forms.TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, string? text, System.Drawing.Font? font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor, System.Windows.Forms.TextFormatFlags flags);
static member DrawText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Rectangle * System.Drawing.Color * System.Windows.Forms.TextFormatFlags -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As String, font As Font, bounds As Rectangle, foreColor As Color, flags As TextFormatFlags)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
String

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

bounds
Rectangle

텍스트의 범위를 나타내는 Rectangle입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

예외

dc이(가) null인 경우

예제

다음 코드 예제에서는 DrawText 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행 하려면 호출을 Windows Form에 코드를 붙여넣은 RenderText6 폼의 Paint 이벤트 처리기를 전달 e 으로 PaintEventArgs입니다.

private void RenderText6(PaintEventArgs e)
{
    TextFormatFlags flags = TextFormatFlags.Bottom | TextFormatFlags.EndEllipsis;
    TextRenderer.DrawText(e.Graphics, "This is some text that will be clipped at the end.", this.Font,
        new Rectangle(10, 10, 100, 50), SystemColors.ControlText, flags);
}
Private Sub RenderText6(ByVal e As PaintEventArgs)
    Dim flags As TextFormatFlags = TextFormatFlags.Bottom Or _
        TextFormatFlags.EndEllipsis
    TextRenderer.DrawText(e.Graphics, _
    "This is some text that will be clipped at the end.", _
    Me.Font, New Rectangle(10, 10, 100, 50), SystemColors.ControlText, flags)

End Sub

설명

경우 font 또는 color 됩니다 null 또는 Empty각각; 합니다 DrawText 메서드 글꼴 또는 색으로 지정 된 디바이스 컨텍스트에서 현재 선택 된 텍스트를 그립니다 dc합니다. 하는 경우 forecolorTransparent, 텍스트를 가져오게 됩니다.

DrawText 매개 변수를 사용하는 TextFormatFlags 오버로드 중 하나를 사용하여 텍스트를 그리는 방법을 조작할 수 있습니다. 예를 들어, TextRenderer의 기본 동작은 걸친 모양의 문자를 표시하기 위해 그린 텍스트의 경계 사각형에 여백을 추가하는 것입니다. 이러한 추가 공간 없이 한 줄의 텍스트를 그려야 하는 경우 DrawTextMeasureText 매개 변수를 사용하는 SizeTextFormatFlags의 버전을 사용해야 합니다. 예제를 보려면 MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags)를 참조하세요.

제공 하는 텍스트 렌더링을 TextRenderer 클래스는 GDI 텍스트 렌더링에 기반 하며 Windows Forms의 인쇄에 지원 되지 않습니다. 대신 사용 합니다 DrawString 의 메서드는 Graphics 클래스.

합니다 TextRenderer 사용을 중지할 기존 탭을 확장할 수 있지만 그린된 텍스트에 탭 정지를 추가 하는 지원 하지 않습니다는 ExpandTabs 플래그입니다.

적용 대상

DrawText(IDeviceContext, String, Font, Rectangle, Color, Color)

지정된 디바이스 컨텍스트, 글꼴, 색 및 배경색을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Rectangle bounds, System::Drawing::Color foreColor, System::Drawing::Color backColor);
public static void DrawText (System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor, System.Drawing.Color backColor);
public static void DrawText (System.Drawing.IDeviceContext dc, string? text, System.Drawing.Font? font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor, System.Drawing.Color backColor);
static member DrawText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Rectangle * System.Drawing.Color * System.Drawing.Color -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As String, font As Font, bounds As Rectangle, foreColor As Color, backColor As Color)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
String

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

bounds
Rectangle

텍스트의 범위를 나타내는 Rectangle입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

backColor
Color

bounds가 나타내는 영역에 적용할 Color입니다.

예외

dc이(가) null인 경우

예제

다음 코드 예제에서는 DrawText 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행 하려면 호출을 Windows Form에 코드를 붙여넣은 RenderText4 폼의 Paint 이벤트 처리기를 전달 e 으로 PaintEventArgs입니다.

private void RenderText4(PaintEventArgs e)
{
    TextRenderer.DrawText(e.Graphics, "Regular Text.", this.Font,
        new Rectangle(10, 10, 70, 70), SystemColors.ControlText, 
        SystemColors.ControlDark);
}
Private Sub RenderText4(ByVal e As PaintEventArgs)
    TextRenderer.DrawText(e.Graphics, "Regular Text.", _
        Me.Font, New Rectangle(10, 10, 70, 70), _
        SystemColors.ControlText, SystemColors.ControlDark)

End Sub

설명

합니다 backColor 내의 영역으로 매개 변수가 적용 되는 bounds 매개 변수입니다. 경우 font, backcolor 또는 forecolornull 또는 Empty각각; 합니다 DrawText 메서드는 글꼴의 색으로 지정 된 디바이스 컨텍스트에서 현재 선택 된 텍스트를 그립니다. dc합니다. 하는 경우 forecolorTransparent, 텍스트를 가져오게 됩니다.

이 메서드 생성 하 여 지정 된 사각형의 가로 및 세로로 가운데 맞춤 된 텍스트에서를 bounds 매개 변수입니다. 텍스트를 그리는 방법을 변경 하려면 버전을 사용 DrawText 를 사용 하는 한 TextFormatFlags 매개 변수 형식입니다.

제공 하는 텍스트 렌더링을 TextRenderer 클래스는 GDI 텍스트 렌더링에 기반 하며 Windows Forms의 인쇄에 지원 되지 않습니다. 대신 사용 합니다 DrawString 의 메서드는 Graphics 클래스.

적용 대상

DrawText(IDeviceContext, String, Font, Point, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색 및 서식 명령을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Point pt, System::Drawing::Color foreColor, System::Windows::Forms::TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Point pt, System.Drawing.Color foreColor, System.Windows.Forms.TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, string? text, System.Drawing.Font? font, System.Drawing.Point pt, System.Drawing.Color foreColor, System.Windows.Forms.TextFormatFlags flags);
static member DrawText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Point * System.Drawing.Color * System.Windows.Forms.TextFormatFlags -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As String, font As Font, pt As Point, foreColor As Color, flags As TextFormatFlags)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
String

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

pt
Point

그린 텍스트의 왼쪽 위 모퉁이를 나타내는 Point입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

예외

dc이(가) null인 경우

예제

다음 코드 예제에서는 DrawText 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행 하려면 호출을 Windows Form에 코드를 붙여넣은 RenderText5 폼의 Paint 이벤트 처리기를 전달 e 으로 PaintEventArgs입니다.

private void RenderText5(PaintEventArgs e)
{
    TextRenderer.DrawText(e.Graphics, "Some text.",
        this.Font, new Point(10, 10), SystemColors.ControlText, TextFormatFlags.Bottom);
}
Private Sub RenderText5(ByVal e As PaintEventArgs)
    TextRenderer.DrawText(e.Graphics, "Some text.", _
    Me.Font, New Point(10, 10), SystemColors.ControlText, _
    TextFormatFlags.Bottom)

End Sub

설명

DrawText 매개 변수를 사용하는 TextFormatFlags 오버로드 중 하나를 사용하여 텍스트를 그리는 방법을 조작할 수 있습니다. 예를 들어, TextRenderer의 기본 동작은 걸친 모양의 문자를 표시하기 위해 그린 텍스트의 경계 사각형에 여백을 추가하는 것입니다. 이러한 추가 공간 없이 한 줄의 텍스트를 그려야 하는 경우 DrawTextMeasureText 매개 변수를 사용하는 SizeTextFormatFlags의 버전을 사용해야 합니다. 예제를 보려면 MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags)를 참조하세요.

합니다 backColor 내의 영역으로 매개 변수가 적용 되는 bounds 매개 변수입니다. 경우 font 또는 forecolor 됩니다 null 또는 Color.Empty각각; 합니다 DrawText 메서드 글꼴 또는 색으로 지정 된 디바이스 컨텍스트에서 현재 선택 된 텍스트를 그립니다 dc합니다. 하는 경우 forecolorTransparent, 텍스트를 가져오게 됩니다.

제공 하는 텍스트 렌더링을 TextRenderer 클래스는 GDI 텍스트 렌더링에 기반 하며 Windows Forms의 인쇄에 지원 되지 않습니다. 대신 사용 합니다 DrawString 의 메서드는 Graphics 클래스.

합니다 TextRenderer 사용을 중지할 기존 탭을 확장할 수 있지만 그린된 텍스트에 탭 정지를 추가 하는 지원 하지 않습니다는 ExpandTabs 플래그입니다.

참고

합니다 DrawText 지정 하는 메서드를 Point 그려지는 텍스트의 왼쪽 위 모퉁이를 제대로 렌더링 되지 않는 Windows 2000에서. 애플리케이션 Windows 2000을 실행 하는 컴퓨터에서 사용 하기 위한, 하나를 사용 해야 하는 DrawText 지정 하는 메서드를 Rectangle 그려지는 텍스트의 범위에 대 한 합니다.

적용 대상

DrawText(IDeviceContext, String, Font, Point, Color, Color)

지정된 디바이스 컨텍스트, 글꼴, 색 및 배경색을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Point pt, System::Drawing::Color foreColor, System::Drawing::Color backColor);
public static void DrawText (System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Point pt, System.Drawing.Color foreColor, System.Drawing.Color backColor);
public static void DrawText (System.Drawing.IDeviceContext dc, string? text, System.Drawing.Font? font, System.Drawing.Point pt, System.Drawing.Color foreColor, System.Drawing.Color backColor);
static member DrawText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Point * System.Drawing.Color * System.Drawing.Color -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As String, font As Font, pt As Point, foreColor As Color, backColor As Color)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
String

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

pt
Point

그린 텍스트의 왼쪽 위 모퉁이를 나타내는 Point입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

backColor
Color

그린 텍스트의 배경 영역에 적용할 Color입니다.

예외

dc이(가) null인 경우

예제

다음 코드 예제에서는 DrawText 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행 하려면 호출을 Windows Form에 코드를 붙여넣은 RenderText3 폼의 Paint 이벤트 처리기를 전달 e 으로 PaintEventArgs입니다.

private void RenderText3(PaintEventArgs e)
{
    TextRenderer.DrawText(e.Graphics, "Regular Text", this.Font,
        new Point(10, 10), Color.Red, Color.PowderBlue);
}
Private Sub RenderText3(ByVal e As PaintEventArgs)
    TextRenderer.DrawText(e.Graphics, "Regular Text", Me.Font, _
        New Point(10, 10), Color.Red, Color.PowderBlue)

End Sub

설명

backColor 그린된 텍스트를 포함 하는 사각형 영역에 매개 변수가 적용 됩니다. 경우 font, backcolor 또는 forecolornull 또는 Color.Empty각각; 합니다 DrawText 메서드는 글꼴의 색으로 지정 된 디바이스 컨텍스트에서 현재 선택 된 텍스트를 그립니다. dc합니다. 하는 경우 forecolorTransparent, 텍스트를 가져오게 됩니다.

DrawText 매개 변수를 사용하는 TextFormatFlags 오버로드 중 하나를 사용하여 텍스트를 그리는 방법을 조작할 수 있습니다.

제공 하는 텍스트 렌더링을 TextRenderer 클래스는 GDI 텍스트 렌더링에 기반 하며 Windows Forms의 인쇄에 지원 되지 않습니다. 대신 사용 합니다 DrawString 의 메서드는 Graphics 클래스.

참고

합니다 DrawText 지정 하는 메서드를 Point 그려지는 텍스트의 왼쪽 위 모퉁이를 제대로 렌더링 되지 않는 Windows 2000에서. 애플리케이션 Windows 2000을 실행 하는 컴퓨터에서 사용 하기 위한, 하나를 사용 해야 하는 DrawText 지정 하는 메서드를 Rectangle 그려지는 텍스트의 범위에 대 한 합니다.

적용 대상

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Rectangle, Color, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색, 배경색 및 서식 명령을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, ReadOnlySpan<char> text, System::Drawing::Font ^ font, System::Drawing::Rectangle bounds, System::Drawing::Color foreColor, System::Drawing::Color backColor, System::Windows::Forms::TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, ReadOnlySpan<char> text, System.Drawing.Font? font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor, System.Drawing.Color backColor, System.Windows.Forms.TextFormatFlags flags);
static member DrawText : System.Drawing.IDeviceContext * ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Rectangle * System.Drawing.Color * System.Drawing.Color * System.Windows.Forms.TextFormatFlags -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As ReadOnlySpan(Of Char), font As Font, bounds As Rectangle, foreColor As Color, backColor As Color, flags As TextFormatFlags)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
ReadOnlySpan<Char>

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

bounds
Rectangle

텍스트의 범위를 나타내는 Rectangle입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

backColor
Color

그린 텍스트의 배경 영역에 적용할 Color입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

예외

dc이(가) null인 경우

적용 대상

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Rectangle, Color, Color)

지정된 디바이스 컨텍스트, 글꼴, 색 및 배경색을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, ReadOnlySpan<char> text, System::Drawing::Font ^ font, System::Drawing::Rectangle bounds, System::Drawing::Color foreColor, System::Drawing::Color backColor);
public static void DrawText (System.Drawing.IDeviceContext dc, ReadOnlySpan<char> text, System.Drawing.Font? font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor, System.Drawing.Color backColor);
static member DrawText : System.Drawing.IDeviceContext * ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Rectangle * System.Drawing.Color * System.Drawing.Color -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As ReadOnlySpan(Of Char), font As Font, bounds As Rectangle, foreColor As Color, backColor As Color)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
ReadOnlySpan<Char>

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

bounds
Rectangle

텍스트의 범위를 나타내는 Rectangle입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

backColor
Color

그린 텍스트의 배경 영역에 적용할 Color입니다.

예외

dc이(가) null인 경우

적용 대상

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Point, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색 및 서식 명령을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, ReadOnlySpan<char> text, System::Drawing::Font ^ font, System::Drawing::Point pt, System::Drawing::Color foreColor, System::Windows::Forms::TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, ReadOnlySpan<char> text, System.Drawing.Font? font, System.Drawing.Point pt, System.Drawing.Color foreColor, System.Windows.Forms.TextFormatFlags flags);
static member DrawText : System.Drawing.IDeviceContext * ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Point * System.Drawing.Color * System.Windows.Forms.TextFormatFlags -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As ReadOnlySpan(Of Char), font As Font, pt As Point, foreColor As Color, flags As TextFormatFlags)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
ReadOnlySpan<Char>

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

pt
Point

그린 텍스트의 왼쪽 위 모퉁이를 나타내는 Point입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

예외

dc이(가) null인 경우

적용 대상

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Point, Color, Color)

지정된 디바이스 컨텍스트, 글꼴, 색 및 배경색을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, ReadOnlySpan<char> text, System::Drawing::Font ^ font, System::Drawing::Point pt, System::Drawing::Color foreColor, System::Drawing::Color backColor);
public static void DrawText (System.Drawing.IDeviceContext dc, ReadOnlySpan<char> text, System.Drawing.Font font, System.Drawing.Point pt, System.Drawing.Color foreColor, System.Drawing.Color backColor);
static member DrawText : System.Drawing.IDeviceContext * ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Point * System.Drawing.Color * System.Drawing.Color -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As ReadOnlySpan(Of Char), font As Font, pt As Point, foreColor As Color, backColor As Color)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
ReadOnlySpan<Char>

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

pt
Point

그린 텍스트의 왼쪽 위 모퉁이를 나타내는 Point입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

backColor
Color

그린 텍스트의 배경 영역에 적용할 Color입니다.

예외

dc이(가) null인 경우

적용 대상

DrawText(IDeviceContext, String, Font, Rectangle, Color)

지정된 디바이스 컨텍스트, 글꼴 및 색을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Rectangle bounds, System::Drawing::Color foreColor);
public static void DrawText (System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor);
public static void DrawText (System.Drawing.IDeviceContext dc, string? text, System.Drawing.Font? font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor);
static member DrawText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Rectangle * System.Drawing.Color -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As String, font As Font, bounds As Rectangle, foreColor As Color)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
String

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

bounds
Rectangle

텍스트의 범위를 나타내는 Rectangle입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

예외

dc이(가) null인 경우

예제

다음 코드 예제에서는 DrawText 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행 하려면 호출을 Windows Form에 코드를 붙여넣은 RenderText2 폼의 Paint 이벤트 처리기를 전달 e 으로 PaintEventArgs입니다.

private void RenderText2(PaintEventArgs e)
{
    TextRenderer.DrawText(e.Graphics, "Regular Text", this.Font,
        new Rectangle(10, 10, 100, 100), SystemColors.ControlText);
}
Private Sub RenderText2(ByVal e As PaintEventArgs)
    TextRenderer.DrawText(e.Graphics, "Regular Text", _
        Me.Font, New Rectangle(10, 10, 100, 100), _
        SystemColors.ControlText)

End Sub

설명

경우 font 또는 forecolor 됩니다 null 또는 Color.Empty각각; 합니다 DrawText 메서드 글꼴 또는 색으로 지정 된 디바이스 컨텍스트에서 현재 선택 된 텍스트를 그립니다 dc합니다. 하는 경우 forecolorTransparent, 텍스트를 가져오게 됩니다.

이 메서드 생성 하 여 지정 된 사각형의 가로 및 세로로 가운데 맞춤 된 텍스트에서를 bounds 매개 변수입니다. 텍스트를 그리는 방법을 변경 하려면 버전을 사용 DrawText 를 사용 하는 한 TextFormatFlags 매개 변수 형식입니다.

제공 하는 텍스트 렌더링을 TextRenderer 클래스는 GDI 텍스트 렌더링에 기반 하며 Windows Forms의 인쇄에 지원 되지 않습니다. 대신 사용 합니다 DrawString 의 메서드는 Graphics 클래스.

추가 정보

적용 대상

DrawText(IDeviceContext, String, Font, Point, Color)

지정된 디바이스 컨텍스트, 글꼴 및 색을 사용하여 지정된 위치에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Point pt, System::Drawing::Color foreColor);
public static void DrawText (System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Point pt, System.Drawing.Color foreColor);
public static void DrawText (System.Drawing.IDeviceContext dc, string? text, System.Drawing.Font? font, System.Drawing.Point pt, System.Drawing.Color foreColor);
static member DrawText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Point * System.Drawing.Color -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As String, font As Font, pt As Point, foreColor As Color)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
String

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

pt
Point

그린 텍스트의 왼쪽 위 모퉁이를 나타내는 Point입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

예외

dc이(가) null인 경우

예제

다음 코드 예제에서는 DrawText 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행 하려면 호출을 Windows Form에 코드를 붙여넣은 RenderText1 폼의 Paint 이벤트 처리기를 전달 e 으로 PaintEventArgs입니다.

private void RenderText1(PaintEventArgs e)
{
    TextRenderer.DrawText(e.Graphics, "Regular Text", this.Font, 
        new Point(10, 10), SystemColors.ControlText);
}
Private Sub RenderText1(ByVal e As PaintEventArgs)
    TextRenderer.DrawText(e.Graphics, "Regular Text", _
        Me.Font, New Point(10, 10), SystemColors.ControlText)

End Sub

설명

DrawText 매개 변수를 사용하는 TextFormatFlags 오버로드 중 하나를 사용하여 텍스트를 그리는 방법을 조작할 수 있습니다.

경우 font 됩니다 null 또는 forecolor 됩니다 Color.EmptyDrawText 메서드 글꼴 또는 색으로 지정 된 디바이스 컨텍스트에서 현재 선택 된 텍스트를 그립니다 dc. 하는 경우 forecolorTransparent, 텍스트를 가져오게 됩니다.

제공 하는 텍스트 렌더링을 TextRenderer 클래스는 GDI 텍스트 렌더링에 기반 하며 Windows Forms의 인쇄에 지원 되지 않습니다. 대신 사용 합니다 DrawString 의 메서드는 Graphics 클래스.

참고

합니다 DrawText 지정 하는 메서드를 Point 그려지는 텍스트의 왼쪽 위 모퉁이를 제대로 렌더링 되지 않는 Windows 2000에서. 애플리케이션 Windows 2000을 실행 하는 컴퓨터에서 사용 하기 위한, 하나를 사용 해야 하는 DrawText 지정 하는 메서드를 Rectangle 그려지는 텍스트의 범위에 대 한 합니다.

추가 정보

적용 대상

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Rectangle, Color)

지정된 디바이스 컨텍스트, 글꼴 및 색을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, ReadOnlySpan<char> text, System::Drawing::Font ^ font, System::Drawing::Rectangle bounds, System::Drawing::Color foreColor);
public static void DrawText (System.Drawing.IDeviceContext dc, ReadOnlySpan<char> text, System.Drawing.Font? font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor);
static member DrawText : System.Drawing.IDeviceContext * ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Rectangle * System.Drawing.Color -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As ReadOnlySpan(Of Char), font As Font, bounds As Rectangle, foreColor As Color)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
ReadOnlySpan<Char>

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

bounds
Rectangle

텍스트의 범위를 나타내는 Rectangle입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

예외

dc이(가) null인 경우

적용 대상

DrawText(IDeviceContext, ReadOnlySpan<Char>, Font, Rectangle, Color, TextFormatFlags)

지정된 디바이스 컨텍스트, 글꼴, 색 및 서식 명령을 사용하여 지정된 범위에 지정된 텍스트를 그립니다.

public:
 static void DrawText(System::Drawing::IDeviceContext ^ dc, ReadOnlySpan<char> text, System::Drawing::Font ^ font, System::Drawing::Rectangle bounds, System::Drawing::Color foreColor, System::Windows::Forms::TextFormatFlags flags);
public static void DrawText (System.Drawing.IDeviceContext dc, ReadOnlySpan<char> text, System.Drawing.Font? font, System.Drawing.Rectangle bounds, System.Drawing.Color foreColor, System.Windows.Forms.TextFormatFlags flags);
static member DrawText : System.Drawing.IDeviceContext * ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Rectangle * System.Drawing.Color * System.Windows.Forms.TextFormatFlags -> unit
Public Shared Sub DrawText (dc As IDeviceContext, text As ReadOnlySpan(Of Char), font As Font, bounds As Rectangle, foreColor As Color, flags As TextFormatFlags)

매개 변수

dc
IDeviceContext

텍스트를 그릴 디바이스 컨텍스트입니다.

text
ReadOnlySpan<Char>

그릴 텍스트입니다.

font
Font

그린 텍스트에 적용할 Font입니다.

bounds
Rectangle

텍스트의 범위를 나타내는 Rectangle입니다.

foreColor
Color

그린 텍스트에 적용할 Color입니다.

flags
TextFormatFlags

TextFormatFlags 값의 비트 조합입니다.

예외

dc이(가) null인 경우

적용 대상