어셈블리: System.Windows.Forms(system.windows.forms.dll)
Public Shared Sub DrawText ( _ dc As IDeviceContext, _ text As String, _ font As Font, _ pt As Point, _ foreColor As Color _ )
Dim dc As IDeviceContext Dim text As String Dim font As Font Dim pt As Point Dim foreColor As Color TextRenderer.DrawText(dc, text, font, pt, foreColor)
public static void DrawText ( IDeviceContext dc, string text, Font font, Point pt, Color foreColor )
public: static void DrawText ( IDeviceContext^ dc, String^ text, Font^ font, Point pt, Color foreColor )
public static void DrawText ( IDeviceContext dc, String text, Font font, Point pt, Color foreColor )
public static function DrawText ( dc : IDeviceContext, text : String, font : Font, pt : Point, foreColor : Color )
매개 변수
- dc
-
텍스트를 그릴 디바이스 컨텍스트입니다.
- text
-
그릴 텍스트입니다.
- font
-
그린 텍스트에 적용할 Font입니다.
- pt
-
그린 텍스트의 왼쪽 위 모퉁이를 나타내는 Point입니다.
- foreColor
-
그린 텍스트에 적용할 Color입니다.
| 예외 형식 | 조건 |
|---|---|
| dc가 Null 참조(Visual Basic의 경우 Nothing)인 경우 |
TextFormatFlags 매개 변수를 사용하는 DrawText 오버로드 중 하나를 사용하여 텍스트를 그리는 방법을 조작할 수 있습니다.
font가 Null 참조(Visual Basic의 경우 Nothing)이거나 forecolor가 Color.Empty이면 DrawText 메서드가 dc에 지정된 디바이스 컨텍스트에서 현재 선택된 글꼴이나 색으로 텍스트를 그립니다. forecolor가 Transparent이면 텍스트가 그려지지 않습니다.
TextRenderer 클래스에서 제공하는 텍스트 렌더링은 GDI 텍스트 렌더링을 기반으로 하며, Windows Forms에서 인쇄하는 데는 사용할 수 없습니다. 대신 Graphics 클래스의 DrawString 메서드를 사용합니다.
다음 코드 예제에서는 DrawText 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행하려면 Windows Form에 코드를 붙여넣은 다음 폼의 Paint 이벤트 처리기에서 RenderText1을 호출하고 e를 PaintEventArgs로 전달합니다.
Private Sub RenderText1(ByVal e As PaintEventArgs) TextRenderer.DrawText(e.Graphics, "Regular Text", _ Me.Font, New Point(10, 10), SystemColors.ControlText) End Sub
private void RenderText1(PaintEventArgs e) { TextRenderer.DrawText(e.Graphics, "Regular Text", this.Font, new Point(10, 10), SystemColors.ControlText); }
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.