vb.net - 在同一页面但在打印文档 vb.net 的下一列中显示多余的数据
问题描述
所以我有打印文档显示来自我的datagridview的数据,我的问题是我想计算我的datagridview中的行,然后如果行超过10,它将切割数据1-10,然后在下一个显示剩余数据第 10-15 列以上。我一直坚持只显示数据,直到它到达页面的底部边缘,当它到达时,数据将转到下一页。
所以我想要这样看图片
但我只有这样的输出
计数 11 依此类推,直到到达底部边距,然后剩余的数据将转到下一页。
我怎样才能做到这一点?任何想法?
我的datagridview只有这个代码`
Dim mRow As Integer = 0
Dim newpage As Boolean = True
With dtgridvwPrint
Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
fmt.LineAlignment = StringAlignment.Center
fmt.Trimming = StringTrimming.EllipsisCharacter
Dim y As Single = e.PageBounds.Height - 700
Do While mRow < .RowCount
Dim row As DataGridViewRow = .Rows(mRow)
Dim x As Single = e.MarginBounds.Left
Dim h As Single = 0
Dim x1 As Single = e.PageBounds.Width - 500
Dim count As Integer
For Each rows As DataGridViewRow In dtgridvwPrint.Rows
count += dtgridvwPrint.RowCount
Next
For Each cell As DataGridViewCell In row.Cells
Dim rc As RectangleF = New RectangleF(x, y, cell.Size.Width, cell.Size.Height)
'e.Graphics.DrawRectangle(Pens.Black, rc.Left, rc.Top, rc.Width, rc.Height)
If (newpage) Then
e.Graphics.DrawString(dtgridvwPrint.Columns(cell.ColumnIndex).HeaderText, font1, Brushes.Black, rc, fmt)
Else
e.Graphics.DrawString(dtgridvwPrint.Rows(cell.RowIndex).Cells(cell.ColumnIndex).FormattedValue.ToString(), font, Brushes.Black, rc, fmt)
End If
x += rc.Width
h = Math.Max(h, rc.Height)
Next
newpage = False
y += h
mRow += 1
If y + h > e.MarginBounds.Bottom Then
e.HasMorePages = True
mRow -= 1
newpage = True
Exit Sub
End If
Loop
mRow = 0
End With `
解决方案
推荐阅读
- c++ - C++:处理许多配置变量的设计建议
- javascript - 根据 localStorage 有条件地渲染组件
- python - Logistic 回归的交叉验证指标
- node.js - 如何使用nodejs从couchdb下载附件
- amazon-web-services - 为什么在 AWS 安全组的入站 IP 地址中指定 cidr 范围
- php - Prestashop 显示产品类别和子类别
- python - Django将多个实例的HttpResponse转换为PDF并压缩它们不起作用
- python - 如何按值获取行名和列名?
- html - 使范围 HTML 输入类型样式在 Chrome 和 Internet Explorer 之间兼容
- django - 在 django restframework 或客户响应中使用带有 get_queryset 方法的响应代码或消息