大佬教程收集整理的这篇文章主要介绍了vb.net – 以横向格式打印和预览DataGridView,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Private Sub btnPreview_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnPreview.Click preview.PrintPreviewControl.Zoom = 1 preview.Document = print print.PrinterSetTings.DefaultPageSetTings.Landscape = True preview.Show() AddHandler print.PrintPage,AddressOf print_PrintPage End Sub Protected Sub print_PrintPage(ByVal sender As Object,ByVal e As PrintPageEventArgs) Dim columnCount As Integer = DataGridView1.columnCount Dim RowCount As Integer = DataGridView1.RowCount Dim CellTopPos As Integer = print.PrinterSetTings.DefaultPageSetTings.Margins.Top For Row = 0 To RowCount - 1 Dim CellLeftPos As Integer = print.PrinterSetTings.DefaultPageSetTings.Margins.Left For Cell = 0 To columnCount - 1 Dim CellValue As String = DataGridView1.Rows(Row).Cells(Cell).Value.ToString() Dim CellWidth = DataGridView1.Rows(Row).Cells(Cell).Size.Width + 50 Dim CellHeight = DataGridView1.Rows(Row).Cells(Cell).Size.Height Dim Brush As New SolidBrush(Color.black) e.Graphics.DrawString(CellValue,New Font("Century Gothic",10),Brush,CellLeftPos,CellTopPos) e.Graphics.DrawRectangle(Pens.black,CellTopPos,CellWidth,CellHeight) CellLeftPos += CellWidth Next CellTopPos += DataGridView1.Rows(Row).Cells(0).Size.Height Next End Sub
这是我预览和打印datagridview内容的代码.我尝试使用DefaultPageSetTings代码,但它不起作用.我也试图以中心格式打印它
'PrintDocument1.PrinterSetTings.DefaultPageSetTings.Landscape = True PrintDocument1.DefaultPageSetTings.Landscape = True
以上是大佬教程为你收集整理的vb.net – 以横向格式打印和预览DataGridView全部内容,希望文章能够帮你解决vb.net – 以横向格式打印和预览DataGridView所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。