Graphics.DrawString Method (String, Font, Brush, PointF, StringFormat)
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family
Show All
Draws the specified text string at the specified location with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.[C#]
[ComVisible(false)]
public void DrawString(
string s,
Font font,
Brush brush,
PointF point,
StringFormat format
);
Parameters
s
String to draw.
font
Font object that defines the text format of the string.
brush
Brush object that determines the color and texture of the drawn text.
point
PointF structure that specifies the upper-left corner of the drawn text.
format
StringFormat object that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.
Return Value
This method does not return a value.Example
[C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions: Creates a text string to draw.
Defines the font as Arial (16pt).
Creates a solid, black brush to draw with.
Creates a point for the upper-left corner at which to draw the text.
Sets the format of the string to draw vertically.
Draws the string to the screen using the font, brush, destination point and format.
[C#]
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);
}
-------------------------------------------------------------------
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family
Show All
Draws the specified text string at the specified location with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.[C#]
[ComVisible(false)]
public void DrawString(
string s,
Font font,
Brush brush,
PointF point,
StringFormat format
);
Parameters
s
String to draw.
font
Font object that defines the text format of the string.
brush
Brush object that determines the color and texture of the drawn text.
point
PointF structure that specifies the upper-left corner of the drawn text.
format
StringFormat object that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.
Return Value
This method does not return a value.Example
[C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions: Creates a text string to draw.
Defines the font as Arial (16pt).
Creates a solid, black brush to draw with.
Creates a point for the upper-left corner at which to draw the text.
Sets the format of the string to draw vertically.
Draws the string to the screen using the font, brush, destination point and format.
[C#]
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);
}
-------------------------------------------------------------------
解决方案 »
- C# 如何做条码识别与指纹识别软件啊?
- 新手求教C#的问题
- build和debug运行同一程序,其结果是否有差别?(求助)
- treeview只想最终节点显示checkbox
- 用语句写不同电脑上的sql数据库的不同表之间的数据复制
- 如何提高往数据库连续插入数据的效率?请大家帮忙!!
- 请教在.NET中连接远程数据库出错的原因
- winform picturebox 怎样显示视频
- 怎么数据库连接实现和DropDownList一样的效果
- 如何让用户自定义控件(UserControl 类继承的)也能够有ShowDialog()的方法
- 麻烦给俺扫下盲:“CrystalReport”是什么意思,以及它用途和特点,谢谢!
- tcpClient的问题
怎么你也用这个名字?