Graphics.DrawString 메서드 (String, Font, Brush, PointF, StringFormat)
어셈블리: System.Drawing(system.drawing.dll)
public void DrawString ( string s, Font font, Brush brush, PointF point, StringFormat format )
public void DrawString ( String s, Font font, Brush brush, PointF point, StringFormat format )
public function DrawString ( s : String, font : Font, brush : Brush, point : PointF, format : StringFormat )
매개 변수
- s
그릴 문자열입니다.
- font
문자열의 텍스트 형식을 정의하는 Font입니다.
- brush
그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.
- point
그려지는 이미지의 왼쪽 위 모퉁이를 지정하는 PointF 구조체입니다.
- format
그릴 텍스트에 적용되는 줄 간격 및 맞춤과 같은 서식 특성을 지정하는 StringFormat입니다.
다음 코드 예제는 Windows Forms에 적용되며, 여기에는 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse가 필요합니다. 이 코드는 다음 작업을 수행합니다.
-
그릴 텍스트 문자열을 만듭니다.
-
글꼴을Arial(16pt)로 정의합니다.
-
그리는 데 사용할 단색의 검정 브러시를 만듭니다.
-
텍스트를 그릴 왼쪽 위 모퉁이에 대한 점을 만듭니다.
-
세로로 그릴 문자열의 형식을 설정합니다.
-
글꼴, 브러시, 대상 점 및 형식을 사용하여 화면에 문자열을 그립니다.
public void DrawStringPointFFormat(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, 50.0F); // Set format of string. StringFormat drawFormat = new StringFormat(); drawFormat.FormatFlags = StringFormatFlags.DirectionVertical; // Draw string to screen. e.Graphics.DrawString(drawString, drawFont, drawBrush, drawPoint, drawFormat); }
public void DrawStringPointFFormat(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, 50);
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.set_FormatFlags(StringFormatFlags.DirectionVertical);
// Draw string to screen.
e.get_Graphics().DrawString(drawString, drawFont, drawBrush, drawPoint,
drawFormat);
} //DrawStringPointFFormat
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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.