// 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);使用 StringFormat 类来控制
应该不需要用stringFormat来控制吧?可以使用drawPoint来指定坐标吧 drawString("摩天", New font("宋体",9,fontstyle.bold),new SolidBrush(Color.White),New pointF(160,50))
把字拆成数组,然后循环.加Y坐标. While count < linesPerPage line = streamToPrint.ReadLine() If line Is Nothing Then Exit While End If yPos = topMargin + count * printFont.GetHeight(ev.Graphics) ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat()) count += 1 End While
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);使用 StringFormat 类来控制
drawString("摩天", New font("宋体",9,fontstyle.bold),new
SolidBrush(Color.White),New pointF(160,50))
While count < linesPerPage
line = streamToPrint.ReadLine()
If line Is Nothing Then
Exit While
End If
yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())
count += 1
End While