Graphics.DrawString メソッド (String, Font, Brush, RectangleF)
アセンブリ: System.Drawing (system.drawing.dll 内)

Public Sub DrawString ( _ s As String, _ font As Font, _ brush As Brush, _ layoutRectangle As RectangleF _ )
Dim instance As Graphics Dim s As String Dim font As Font Dim brush As Brush Dim layoutRectangle As RectangleF instance.DrawString(s, font, brush, layoutRectangle)

例外の種類 | 条件 |
---|---|
ArgumentNullException | brush が null 参照 (Visual Basic では Nothing) です。 または s が null 参照 (Visual Basic では Nothing) です。 |

s パラメータによって表されるテキストは、layoutRectangle パラメータによって表される四角形の内部に描画されます。四角形の内部に収まらないテキストは最も近い単語に切り捨てられます。四角形内での文字列の描画方法を指定するには、StringFormat を受け取る DrawString オーバーロードを使用します。

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードは次のアクションを実行します。
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
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: 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.get_Black()); // Create rectangle for drawing. float x = 150; float y = 150; float width = 200; float height = 50; RectangleF drawRect = new RectangleF(x, y, width, height); // Draw rectangle to screen. Pen blackPen = new Pen(Color.get_Black()); e.get_Graphics().DrawRectangle(blackPen, x, y, width, height); // Draw string to screen. e.get_Graphics().DrawString(drawString, drawFont, drawBrush, drawRect); } //DrawStringRectangleF

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Graphics.DrawString メソッド (String, Font, Brush, RectangleF, StringFormat)
アセンブリ: System.Drawing (system.drawing.dll 内)

Public Sub DrawString ( _ s As String, _ font As Font, _ brush As Brush, _ layoutRectangle As RectangleF, _ format As StringFormat _ )
Dim instance As Graphics Dim s As String Dim font As Font Dim brush As Brush Dim layoutRectangle As RectangleF Dim format As StringFormat instance.DrawString(s, font, brush, layoutRectangle, format)
public void DrawString ( string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format )
public: void DrawString ( String^ s, Font^ font, Brush^ brush, RectangleF layoutRectangle, StringFormat^ format )
public void DrawString ( String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format )
public function DrawString ( s : String, font : Font, brush : Brush, layoutRectangle : RectangleF, format : StringFormat )

例外の種類 | 条件 |
---|---|
ArgumentNullException | brush が null 参照 (Visual Basic では Nothing) です。 または s が null 参照 (Visual Basic では Nothing) です。 |

s パラメータによって表されるテキストは、layoutRectangle パラメータによって表される四角形の内部に描画されます。format パラメータで特に指定されていない限り、四角形の内部に収まらないテキストは最も近い単語に切り捨てられます。

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードは次のアクションを実行します。
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
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: 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.get_Black()); // Create rectangle for drawing. float x = 150; float y = 150; float width = 200; float height = 50; RectangleF drawRect = new RectangleF(x, y, width, height); // Draw rectangle to screen. Pen blackPen = new Pen(Color.get_Black()); e.get_Graphics().DrawRectangle(blackPen, x, y, width, height); // Set format of string. StringFormat drawFormat = new StringFormat(); drawFormat.set_Alignment(StringAlignment.Center); // Draw string to screen. e.get_Graphics().DrawString(drawString, drawFont, drawBrush, drawRect, drawFormat); } //DrawStringRectangleFFormat

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Graphics.DrawString メソッド (String, Font, Brush, Single, Single)
アセンブリ: System.Drawing (system.drawing.dll 内)

Public Sub DrawString ( _ s As String, _ font As Font, _ brush As Brush, _ x As Single, _ y As Single _ )
Dim instance As Graphics Dim s As String Dim font As Font Dim brush As Brush Dim x As Single Dim y As Single instance.DrawString(s, font, brush, x, y)

例外の種類 | 条件 |
---|---|
ArgumentNullException | brush が null 参照 (Visual Basic では Nothing) です。 または s が null 参照 (Visual Basic では Nothing) です。 |

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードは次のアクションを実行します。
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
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: 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.get_Black()); // Create point for upper-left corner of drawing. float x = 150; float y = 150; // Draw string to screen. e.get_Graphics().DrawString(drawString, drawFont, drawBrush, x, y); } //DrawStringFloat

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Graphics.DrawString メソッド (String, Font, Brush, PointF)
アセンブリ: System.Drawing (system.drawing.dll 内)

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)

例外の種類 | 条件 |
---|---|
ArgumentNullException | brush が null 参照 (Visual Basic では Nothing) です。 または s が null 参照 (Visual Basic では Nothing) です。 |

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードは次のアクションを実行します。
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Graphics.DrawString メソッド (String, Font, Brush, Single, Single, StringFormat)
アセンブリ: System.Drawing (system.drawing.dll 内)

Public Sub DrawString ( _ s As String, _ font As Font, _ brush As Brush, _ x As Single, _ y As Single, _ format As StringFormat _ )
Dim instance As Graphics Dim s As String Dim font As Font Dim brush As Brush Dim x As Single Dim y As Single Dim format As StringFormat instance.DrawString(s, font, brush, x, y, format)
public: void DrawString ( String^ s, Font^ font, Brush^ brush, float x, float y, StringFormat^ format )
public function DrawString ( s : String, font : Font, brush : Brush, x : float, y : float, format : StringFormat )

例外の種類 | 条件 |
---|---|
ArgumentNullException | brush が null 参照 (Visual Basic では Nothing) です。 または s が null 参照 (Visual Basic では Nothing) です。 |

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードは次のアクションを実行します。
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
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: 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.get_Black()); // Create point for upper-left corner of drawing. float x = 150; float y = 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, x, y, drawFormat); } //DrawStringFloatFormat

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Graphics.DrawString メソッド (String, Font, Brush, PointF, StringFormat)
アセンブリ: System.Drawing (system.drawing.dll 内)

Public Sub DrawString ( _ s As String, _ font As Font, _ brush As Brush, _ point As PointF, _ format As StringFormat _ )
Dim instance As Graphics Dim s As String Dim font As Font Dim brush As Brush Dim point As PointF Dim format As StringFormat instance.DrawString(s, font, brush, point, format)
public function DrawString ( s : String, font : Font, brush : Brush, point : PointF, format : StringFormat )

例外の種類 | 条件 |
---|---|
ArgumentNullException | brush が null 参照 (Visual Basic では Nothing) です。 または s が null 参照 (Visual Basic では Nothing) です。 |

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードは次のアクションを実行します。
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
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. 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.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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Graphics.DrawString メソッド

名前 | 説明 |
---|---|
Graphics.DrawString (String, Font, Brush, PointF) | 指定した位置に、指定した Brush オブジェクトと Font オブジェクトで、指定した文字列を描画します。 |
Graphics.DrawString (String, Font, Brush, RectangleF) | 指定した Brush オブジェクトと Font オブジェクトで、指定した文字列を指定した四角形内に描画します。 .NET Compact Framework によってサポートされています。 |
Graphics.DrawString (String, Font, Brush, PointF, StringFormat) | 指定した StringFormat の書式属性を使用して、指定した Brush オブジェクトおよび Font オブジェクトで、指定した位置に指定した文字列を描画します。 |
Graphics.DrawString (String, Font, Brush, RectangleF, StringFormat) | 指定した StringFormat の書式属性を使用して、指定した Brush オブジェクトおよび Font オブジェクトで、指定した四角形に指定した文字列を描画します。 .NET Compact Framework によってサポートされています。 |
Graphics.DrawString (String, Font, Brush, Single, Single) | 指定した位置に、指定した Brush オブジェクトと Font オブジェクトで、指定した文字列を描画します。 .NET Compact Framework によってサポートされています。 |
Graphics.DrawString (String, Font, Brush, Single, Single, StringFormat) | 指定した StringFormat の書式属性を使用して、指定した Brush オブジェクトおよび Font オブジェクトで、指定した位置に指定した文字列を描画します。 .NET Compact Framework によってサポートされています。 |

Weblioに収録されているすべての辞書からGraphics.DrawStringを検索する場合は、下記のリンクをクリックしてください。

- Graphics.DrawStringのページへのリンク