어셈블리: System.Drawing(system.drawing.dll)
Public Sub DrawString ( _ s As String, _ font As Font, _ brush As Brush, _ point As PointF _ )
Dim instance As Graphics Dim s As String Dim font As Font Dim brush As Brush Dim point As PointF instance.DrawString(s, font, brush, point)
public void DrawString ( string s, Font font, Brush brush, PointF point )
public: void DrawString ( String^ s, Font^ font, Brush^ brush, PointF point )
public void DrawString ( String s, Font font, Brush brush, PointF point )
public function DrawString ( s : String, font : Font, brush : Brush, point : PointF )
매개 변수
- s
-
그릴 문자열입니다.
- font
-
문자열의 텍스트 형식을 정의하는 Font입니다.
- brush
-
그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.
- point
-
그려지는 이미지의 왼쪽 위 모퉁이를 지정하는 PointF 구조체입니다.
| 예외 형식 | 조건 |
|---|---|
| brush가 Null 참조(Visual Basic의 경우 Nothing)인 경우 - 또는 - s가 Null 참조(Visual Basic의 경우 Nothing)인 경우 |
다음 코드 예제는 Windows Forms에 적용되며, 여기에는 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse가 필요합니다. 이 코드는 다음 작업을 수행합니다.
-
그릴 텍스트 문자열을 만듭니다.
-
글꼴을Arial(16pt)로 정의합니다.
-
그리는 데 사용할 단색의 검정 브러시를 만듭니다.
-
텍스트를 그릴 왼쪽 위 모퉁이에 대한 점을 만듭니다.
-
글꼴, 브러시 및 대상 점을 사용하여 화면에 문자열을 그립니다.
Public Sub DrawStringPointF(ByVal e As PaintEventArgs) ' Create string to draw. Dim drawString As [String] = "Sample Text" ' Create font and brush. Dim drawFont As New Font("Arial", 16) Dim drawBrush As New SolidBrush(Color.Black) ' Create point for upper-left corner of drawing. Dim drawPoint As New PointF(150.0F, 150.0F) ' Draw string to screen. e.Graphics.DrawString(drawString, drawFont, drawBrush, drawPoint) End Sub
public void DrawStringPointF(PaintEventArgs e) { // Create string to draw. String drawString = "Sample Text"; // Create font and brush. Font drawFont = new Font("Arial", 16); SolidBrush drawBrush = new SolidBrush(Color.Black); // Create point for upper-left corner of drawing. PointF drawPoint = new PointF(150.0F, 150.0F); // Draw string to screen. e.Graphics.DrawString(drawString, drawFont, drawBrush, drawPoint); }
public: void DrawStringPointF( PaintEventArgs^ e ) { // Create string to draw. String^ drawString = "Sample Text"; // Create font and brush. System::Drawing::Font^ drawFont = gcnew System::Drawing::Font( "Arial",16 ); SolidBrush^ drawBrush = gcnew SolidBrush( Color::Black ); // Create point for upper-left corner of drawing. PointF drawPoint = PointF(150.0F,150.0F); // Draw string to screen. e->Graphics->DrawString( drawString, drawFont, drawBrush, drawPoint ); }
public void DrawStringPointF(PaintEventArgs e)
{
// Create string to draw.
String drawString = "Sample Text";
// Create font and brush.
Font drawFont = new Font("Arial", 16);
SolidBrush drawBrush = new SolidBrush(Color.get_Black());
// Create point for upper-left corner of drawing.
PointF drawPoint = new PointF(150, 150);
// Draw string to screen.
e.get_Graphics().DrawString(drawString, drawFont, drawBrush,
drawPoint);
} //DrawStringPointF
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.