我想将这些数字包装成两行以适合列。目前正在绘制
e.Graphics.DrawString(
ViewA.Rows[sn].Cells["itemcode"].Value.ToString(),
font,
Brushes.Black,
new PointF(e.MarginBounds.Left, un));
当那些string.length > 10
时,我们可以使这些字符串从10. char中换行吗?
例如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;
}