我想将这些数字包装成两行以适合列。目前正在绘制
e.Graphics.DrawString(
ViewA.Rows[sn].Cells["itemcode"].Value.ToString(),
font,
Brushes.Black,
new PointF(e.MarginBounds.Left, un));
我们可以让这些字符串从 10. char 换行string.length > 10
吗?例如 33435356985968 将是
3343535698
5968
编辑:我将代码更改为此。感谢 Henk Holterman,我使用了 rectangleF。有什么可以改善的吗?
string texts;
string measureString = "123456";
Font stringFont = new Font("Arial", 18);
SizeF stringSize = new SizeF();
stringSize = e.Graphics.MeasureString(measureString, stringFont);
for (; sinirr <ViewA.RowCount ; sinirr++)
{
if (ustsin + yuk > e.MarginBounds.Bottom)
{
e.HasMorePages = true;
return;
}
if (ViewA.Rows[sinirr].Cells["itemcode"].Value.ToString().Length > 10)
{
texts = ViewA.Rows[sinirr].Cells["itemcode"].Value.ToString();
graphics.DrawString(texts, font, Brushes.Black, new RectangleF(new PointF(e.MarginBounds.Left, ustsin),stringSize));
ustsin += 2* yuk;
}