Graphics.DrawString 메서드

정의

지정된 위치에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

오버로드

DrawString(String, Font, Brush, Single, Single, StringFormat)

지정된 위치에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(ReadOnlySpan<Char>, Font, Brush, Single, Single, StringFormat)

지정된 위치에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(String, Font, Brush, Single, Single)

지정된 위치에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(String, Font, Brush, RectangleF, StringFormat)

지정된 사각형에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(String, Font, Brush, PointF, StringFormat)

지정된 위치에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(ReadOnlySpan<Char>, Font, Brush, Single, Single)

지정된 위치에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(ReadOnlySpan<Char>, Font, Brush, PointF, StringFormat)

지정된 위치에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(String, Font, Brush, RectangleF)

지정된 사각형에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(String, Font, Brush, PointF)

지정된 위치에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(ReadOnlySpan<Char>, Font, Brush, RectangleF)

지정된 사각형에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(ReadOnlySpan<Char>, Font, Brush, PointF)

지정된 위치에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(ReadOnlySpan<Char>, Font, Brush, RectangleF, StringFormat)

지정된 사각형에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

DrawString(String, Font, Brush, Single, Single, StringFormat)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

지정된 위치에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(System::String ^ s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, float x, float y, System::Drawing::StringFormat ^ format);
public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y, System.Drawing.StringFormat format);
public void DrawString (string? s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y, System.Drawing.StringFormat? format);
member this.DrawString : string * System.Drawing.Font * System.Drawing.Brush * single * single * System.Drawing.StringFormat -> unit
Public Sub DrawString (s As String, font As Font, brush As Brush, x As Single, y As Single, format As StringFormat)

매개 변수

s
String

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

x
Single

그려지는 텍스트의 왼쪽 위 모퉁이에 대한 X좌표입니다.

y
Single

그려지는 텍스트의 왼쪽 위 모퉁이에 대한 Y좌표입니다.

format
StringFormat

그릴 텍스트에 적용되는 줄 간격 및 맞춤과 같은 서식 특성을 지정하는 StringFormat입니다.

예외

brush이(가) null인 경우

또는

snull입니다.

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • 그릴 텍스트 문자열을 만듭니다.

  • 글꼴을 Arial(16pt)으로 정의합니다.

  • 그릴 단색 검은색 브러시를 만듭니다.

  • 텍스트를 그릴 왼쪽 위 모서리에 대한 점의 좌표를 만듭니다.

  • 세로로 그릴 문자열의 형식을 설정합니다.

  • 글꼴, 브러시, 대상 지점 및 형식을 사용하여 문자열을 화면에 그립니다.

public:
   void DrawStringFloatFormat( 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.
      float x = 150.0F;
      float y = 50.0F;

      // Set format of string.
      StringFormat^ drawFormat = gcnew StringFormat;
      drawFormat->FormatFlags = StringFormatFlags::DirectionVertical;

      // Draw string to screen.
      e->Graphics->DrawString( drawString, drawFont, drawBrush, x, y, drawFormat );
   }
public void DrawStringFloatFormat(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.
    float x = 150.0F;
    float y =  50.0F;
             
    // Set format of string.
    StringFormat drawFormat = new StringFormat();
    drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
}
Public Sub DrawStringFloatFormat(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 x As Single = 150.0F
    Dim y As Single = 50.0F

    ' Set format of string.
    Dim drawFormat As New StringFormat
    drawFormat.FormatFlags = StringFormatFlags.DirectionVertical

    ' Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, _
    x, y, drawFormat)
End Sub

추가 정보

적용 대상

DrawString(ReadOnlySpan<Char>, Font, Brush, Single, Single, StringFormat)

Source:
Graphics.cs
Source:
Graphics.cs

지정된 위치에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(ReadOnlySpan<char> s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, float x, float y, System::Drawing::StringFormat ^ format);
public void DrawString (ReadOnlySpan<char> s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y, System.Drawing.StringFormat? format);
member this.DrawString : ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Brush * single * single * System.Drawing.StringFormat -> unit
Public Sub DrawString (s As ReadOnlySpan(Of Char), font As Font, brush As Brush, x As Single, y As Single, format As StringFormat)

매개 변수

s
ReadOnlySpan<Char>

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

x
Single

그려지는 텍스트의 왼쪽 위 모퉁이에 대한 X좌표입니다.

y
Single

그려지는 텍스트의 왼쪽 위 모퉁이에 대한 Y좌표입니다.

format
StringFormat

그릴 텍스트에 적용되는 줄 간격 및 맞춤과 같은 서식 특성을 지정하는 StringFormat입니다.

적용 대상

DrawString(String, Font, Brush, Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

지정된 위치에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(System::String ^ s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, float x, float y);
public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y);
public void DrawString (string? s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y);
member this.DrawString : string * System.Drawing.Font * System.Drawing.Brush * single * single -> unit
Public Sub DrawString (s As String, font As Font, brush As Brush, x As Single, y As Single)

매개 변수

s
String

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

x
Single

그려지는 텍스트의 왼쪽 위 모퉁이에 대한 X좌표입니다.

y
Single

그려지는 텍스트의 왼쪽 위 모퉁이에 대한 Y좌표입니다.

예외

brush이(가) null인 경우

또는

snull입니다.

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • 그릴 텍스트 문자열을 만듭니다.

  • 글꼴을 Arial(16pt)으로 정의합니다.

  • 그릴 단색 검은색 브러시를 만듭니다.

  • 텍스트를 그릴 왼쪽 위 모서리에 대한 점을 만듭니다.

  • 글꼴, 브러시 및 대상 지점을 사용하여 문자열을 화면에 그립니다.

public:
   void DrawStringFloat( 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.
      float x = 150.0F;
      float y = 150.0F;

      // Draw string to screen.
      e->Graphics->DrawString( drawString, drawFont, drawBrush, x, y );
   }
public void DrawStringFloat(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.
    float x = 150.0F;
    float y = 150.0F;
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y);
}
Public Sub DrawStringFloat(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 x As Single = 150.0F
    Dim y As Single = 150.0F

    ' Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y)
End Sub

추가 정보

적용 대상

DrawString(String, Font, Brush, RectangleF, StringFormat)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

지정된 사각형에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(System::String ^ s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, System::Drawing::RectangleF layoutRectangle, System::Drawing::StringFormat ^ format);
public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle, System.Drawing.StringFormat format);
public void DrawString (string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle, System.Drawing.StringFormat? format);
member this.DrawString : string * System.Drawing.Font * System.Drawing.Brush * System.Drawing.RectangleF * System.Drawing.StringFormat -> unit
Public Sub DrawString (s As String, font As Font, brush As Brush, layoutRectangle As RectangleF, format As StringFormat)

매개 변수

s
String

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

layoutRectangle
RectangleF

그려지는 텍스트의 위치를 지정하는 RectangleF 구조체입니다.

format
StringFormat

그릴 텍스트에 적용되는 줄 간격 및 맞춤과 같은 서식 특성을 지정하는 StringFormat입니다.

예외

brush이(가) null인 경우

또는

snull입니다.

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • 그릴 텍스트 문자열을 만듭니다.

  • 글꼴을 Arial(16pt)으로 정의합니다.

  • 그릴 단색 검은색 브러시를 만듭니다.

  • 텍스트를 그릴 사각형을 만듭니다.

  • 사각형을 화면에 그립니다.

  • 직사각형 내에서 가운데에 배치할 문자열의 형식을 설정합니다.

  • 글꼴, 브러시 및 대상 사각형을 사용하여 문자열을 화면에 그립니다.

public:
   void DrawStringRectangleFFormat( 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 rectangle for drawing.
      float x = 150.0F;
      float y = 150.0F;
      float width = 200.0F;
      float height = 50.0F;
      RectangleF drawRect = RectangleF(x,y,width,height);

      // Draw rectangle to screen.
      Pen^ blackPen = gcnew Pen( Color::Black );
      e->Graphics->DrawRectangle( blackPen, x, y, width, height );

      // Set format of string.
      StringFormat^ drawFormat = gcnew StringFormat;
      drawFormat->Alignment = StringAlignment::Center;

      // Draw string to screen.
      e->Graphics->DrawString( drawString, drawFont, drawBrush, drawRect, drawFormat );
   }
public void DrawStringRectangleFFormat(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 rectangle for drawing.
    float x = 150.0F;
    float y = 150.0F;
    float width = 200.0F;
    float height = 50.0F;
    RectangleF drawRect = new RectangleF(x, y, width, height);
             
    // Draw rectangle to screen.
    Pen blackPen = new Pen(Color.Black);
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
             
    // Set format of string.
    StringFormat drawFormat = new StringFormat();
    drawFormat.Alignment = StringAlignment.Center;
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect, drawFormat);
}
Public Sub DrawStringRectangleFFormat(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 rectangle for drawing.
    Dim x As Single = 150.0F
    Dim y As Single = 150.0F
    Dim width As Single = 200.0F
    Dim height As Single = 50.0F
    Dim drawRect As New RectangleF(x, y, width, height)

    ' Draw rectangle to screen.
    Dim blackPen As New Pen(Color.Black)
    e.Graphics.DrawRectangle(blackPen, x, y, width, height)

    ' Set format of string.
    Dim drawFormat As New StringFormat
    drawFormat.Alignment = StringAlignment.Center

    ' Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, _
    drawRect, drawFormat)
End Sub

설명

매개 변수로 s 표시되는 텍스트는 매개 변수가 나타내는 layoutRectangle 사각형 내부에 그려집니다. 텍스트가 사각형 내부에 맞지 않으면 매개 변수로 format 달리 지정하지 않는 한 가장 가까운 단어에서 잘립니다.

추가 정보

적용 대상

DrawString(String, Font, Brush, PointF, StringFormat)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

지정된 위치에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(System::String ^ s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, System::Drawing::PointF point, System::Drawing::StringFormat ^ format);
public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point, System.Drawing.StringFormat format);
public void DrawString (string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point, System.Drawing.StringFormat? format);
member this.DrawString : string * System.Drawing.Font * System.Drawing.Brush * System.Drawing.PointF * System.Drawing.StringFormat -> unit
Public Sub DrawString (s As String, font As Font, brush As Brush, point As PointF, format As StringFormat)

매개 변수

s
String

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

point
PointF

그려지는 이미지의 왼쪽 위 모퉁이를 지정하는 PointF 구조체입니다.

format
StringFormat

그릴 텍스트에 적용되는 줄 간격 및 맞춤과 같은 서식 특성을 지정하는 StringFormat입니다.

예외

brush이(가) null인 경우

또는

snull입니다.

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • 그릴 텍스트 문자열을 만듭니다.

  • 글꼴을 Arial(16pt)으로 정의합니다.

  • 그릴 단색 검은색 브러시를 만듭니다.

  • 텍스트를 그릴 왼쪽 위 모서리에 대한 점을 만듭니다.

  • 세로로 그릴 문자열의 형식을 설정합니다.

  • 글꼴, 브러시, 대상 지점 및 형식을 사용하여 문자열을 화면에 그립니다.

public:
   void DrawStringPointFFormat( 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,50.0F);

      // Set format of string.
      StringFormat^ drawFormat = gcnew 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.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 Sub DrawStringPointFFormat(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, 50.0F)

    ' Set format of string.
    Dim drawFormat As New StringFormat
    drawFormat.FormatFlags = StringFormatFlags.DirectionVertical

    ' Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, _
    drawPoint, drawFormat)
End Sub

추가 정보

적용 대상

DrawString(ReadOnlySpan<Char>, Font, Brush, Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs

지정된 위치에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(ReadOnlySpan<char> s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, float x, float y);
public void DrawString (ReadOnlySpan<char> s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y);
member this.DrawString : ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Brush * single * single -> unit
Public Sub DrawString (s As ReadOnlySpan(Of Char), font As Font, brush As Brush, x As Single, y As Single)

매개 변수

s
ReadOnlySpan<Char>

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

x
Single

그려지는 텍스트의 왼쪽 위 모퉁이에 대한 X좌표입니다.

y
Single

그려지는 텍스트의 왼쪽 위 모퉁이에 대한 Y좌표입니다.

적용 대상

DrawString(ReadOnlySpan<Char>, Font, Brush, PointF, StringFormat)

Source:
Graphics.cs
Source:
Graphics.cs

지정된 위치에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(ReadOnlySpan<char> s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, System::Drawing::PointF point, System::Drawing::StringFormat ^ format);
public void DrawString (ReadOnlySpan<char> s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point, System.Drawing.StringFormat? format);
member this.DrawString : ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Brush * System.Drawing.PointF * System.Drawing.StringFormat -> unit
Public Sub DrawString (s As ReadOnlySpan(Of Char), font As Font, brush As Brush, point As PointF, format As StringFormat)

매개 변수

s
ReadOnlySpan<Char>

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

point
PointF

그려지는 이미지의 왼쪽 위 모퉁이를 지정하는 PointF 구조체입니다.

format
StringFormat

그릴 텍스트에 적용되는 줄 간격 및 맞춤과 같은 서식 특성을 지정하는 StringFormat입니다.

적용 대상

DrawString(String, Font, Brush, RectangleF)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

지정된 사각형에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(System::String ^ s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, System::Drawing::RectangleF layoutRectangle);
public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle);
public void DrawString (string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle);
member this.DrawString : string * System.Drawing.Font * System.Drawing.Brush * System.Drawing.RectangleF -> unit
Public Sub DrawString (s As String, font As Font, brush As Brush, layoutRectangle As RectangleF)

매개 변수

s
String

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

layoutRectangle
RectangleF

그려지는 텍스트의 위치를 지정하는 RectangleF 구조체입니다.

예외

brush이(가) null인 경우

또는

snull입니다.

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • 그릴 텍스트 문자열을 만듭니다.

  • 글꼴을 Arial(16pt)으로 정의합니다.

  • 그릴 단색 검은색 브러시를 만듭니다.

  • 텍스트를 그릴 사각형을 만듭니다.

  • 사각형을 화면에 그립니다.

  • 글꼴, 브러시 및 대상 사각형을 사용하여 문자열을 화면에 그립니다.

public:
   void DrawStringRectangleF( 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 rectangle for drawing.
      float x = 150.0F;
      float y = 150.0F;
      float width = 200.0F;
      float height = 50.0F;
      RectangleF drawRect = RectangleF(x,y,width,height);

      // Draw rectangle to screen.
      Pen^ blackPen = gcnew Pen( Color::Black );
      e->Graphics->DrawRectangle( blackPen, x, y, width, height );

      // Draw string to screen.
      e->Graphics->DrawString( drawString, drawFont, drawBrush, drawRect );
   }
public void DrawStringRectangleF(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 rectangle for drawing.
    float x = 150.0F;
    float y = 150.0F;
    float width = 200.0F;
    float height = 50.0F;
    RectangleF drawRect = new RectangleF(x, y, width, height);
             
    // Draw rectangle to screen.
    Pen blackPen = new Pen(Color.Black);
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect);
}
Public Sub DrawStringRectangleF(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 rectangle for drawing.
    Dim x As Single = 150.0F
    Dim y As Single = 150.0F
    Dim width As Single = 200.0F
    Dim height As Single = 50.0F
    Dim drawRect As New RectangleF(x, y, width, height)

    ' Draw rectangle to screen.
    Dim blackPen As New Pen(Color.Black)
    e.Graphics.DrawRectangle(blackPen, x, y, width, height)

    ' Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect)
End Sub

설명

매개 변수로 s 표시되는 텍스트는 매개 변수가 나타내는 layoutRectangle 사각형 내부에 그려집니다. 텍스트가 사각형 안에 맞지 않으면 가장 가까운 단어에서 잘립니다. 직사각형 내에서 문자열을 그리는 방법을 추가로 조작하려면 를 사용하는 오버로드를 StringFormat사용합니다DrawString.

추가 정보

적용 대상

DrawString(String, Font, Brush, PointF)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

지정된 위치에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(System::String ^ s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, System::Drawing::PointF point);
public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point);
public void DrawString (string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point);
member this.DrawString : string * System.Drawing.Font * System.Drawing.Brush * System.Drawing.PointF -> unit
Public Sub DrawString (s As String, font As Font, brush As Brush, point As PointF)

매개 변수

s
String

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

point
PointF

그려지는 이미지의 왼쪽 위 모퉁이를 지정하는 PointF 구조체입니다.

예외

brush이(가) null인 경우

또는

snull입니다.

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • 그릴 텍스트 문자열을 만듭니다.

  • 글꼴을 Arial(16pt)으로 정의합니다.

  • 그릴 단색 검은색 브러시를 만듭니다.

  • 텍스트를 그릴 왼쪽 위 모서리에 대한 점을 만듭니다.

  • 글꼴, 브러시 및 대상 지점을 사용하여 문자열을 화면에 그립니다.

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.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 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

추가 정보

적용 대상

DrawString(ReadOnlySpan<Char>, Font, Brush, RectangleF)

Source:
Graphics.cs
Source:
Graphics.cs

지정된 사각형에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(ReadOnlySpan<char> s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, System::Drawing::RectangleF layoutRectangle);
public void DrawString (ReadOnlySpan<char> s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle);
member this.DrawString : ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Brush * System.Drawing.RectangleF -> unit
Public Sub DrawString (s As ReadOnlySpan(Of Char), font As Font, brush As Brush, layoutRectangle As RectangleF)

매개 변수

s
ReadOnlySpan<Char>

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

layoutRectangle
RectangleF

그려지는 텍스트의 위치를 지정하는 RectangleF 구조체입니다.

설명

매개 변수로 s 표시되는 텍스트는 매개 변수가 나타내는 layoutRectangle 사각형 내부에 그려집니다. 텍스트가 사각형 안에 맞지 않으면 가장 가까운 단어에서 잘립니다. 직사각형 내에서 문자열을 그리는 방법을 추가로 조작하려면 를 사용하는 오버로드를 StringFormat사용합니다DrawString(ReadOnlySpan<Char>, Font, Brush, RectangleF, StringFormat).

적용 대상

DrawString(ReadOnlySpan<Char>, Font, Brush, PointF)

Source:
Graphics.cs
Source:
Graphics.cs

지정된 위치에 지정된 BrushFont 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(ReadOnlySpan<char> s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, System::Drawing::PointF point);
public void DrawString (ReadOnlySpan<char> s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point);
member this.DrawString : ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Brush * System.Drawing.PointF -> unit
Public Sub DrawString (s As ReadOnlySpan(Of Char), font As Font, brush As Brush, point As PointF)

매개 변수

s
ReadOnlySpan<Char>

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

point
PointF

그려지는 이미지의 왼쪽 위 모퉁이를 지정하는 PointF 구조체입니다.

적용 대상

DrawString(ReadOnlySpan<Char>, Font, Brush, RectangleF, StringFormat)

Source:
Graphics.cs
Source:
Graphics.cs

지정된 사각형에 지정된 Brush의 서식 특성을 사용하여 지정된 FontStringFormat 개체로 지정된 텍스트 문자열을 그립니다.

public:
 void DrawString(ReadOnlySpan<char> s, System::Drawing::Font ^ font, System::Drawing::Brush ^ brush, System::Drawing::RectangleF layoutRectangle, System::Drawing::StringFormat ^ format);
public void DrawString (ReadOnlySpan<char> s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle, System.Drawing.StringFormat? format);
member this.DrawString : ReadOnlySpan<char> * System.Drawing.Font * System.Drawing.Brush * System.Drawing.RectangleF * System.Drawing.StringFormat -> unit
Public Sub DrawString (s As ReadOnlySpan(Of Char), font As Font, brush As Brush, layoutRectangle As RectangleF, format As StringFormat)

매개 변수

s
ReadOnlySpan<Char>

그릴 문자열입니다.

font
Font

문자열의 텍스트 형식을 정의하는 Font입니다.

brush
Brush

그려지는 텍스트의 색과 질감을 결정하는 Brush입니다.

layoutRectangle
RectangleF

그려지는 텍스트의 위치를 지정하는 RectangleF 구조체입니다.

format
StringFormat

그릴 텍스트에 적용되는 줄 간격 및 맞춤과 같은 서식 특성을 지정하는 StringFormat입니다.

적용 대상