加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在横向模式下打印vb.net

发布时间:2020-12-17 07:15:22 所属栏目:百科 来源:网络整理
导读:我已经设法打印我的数据网格视图的内容,但它不适合纵向模式.我想在横向模式下打印它会. 我有我的数据集的代码来填充datagridview. Private Sub print_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load Dim query As St
我已经设法打印我的数据网格视图的内容,但它不适合纵向模式.我想在横向模式下打印它会.

我有我的数据集的代码来填充datagridview.

Private Sub print_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load

    Dim query As String = "SELECT * FROM TBLusers"
    Dim DA As New SqlDataAdapter(query,CN)
    Dim DS As New DataSet
    CN.Open()

    DA.Fill(DS,"Users")
    CN.Close()
    DataGridView1.DataSource = DS.Tables("Users")
    'DataGridView1.DataMember = "Users"


End Sub

这是我猜的打印功能?我是从教程中得到的.

Private Sub printDocument1_PrintPage(ByVal sender As Object,ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

    Dim dataGridViewImage As New Bitmap(Me.DataGridView1.Width,Me.DataGridView1.Height)
    DataGridView1.DrawToBitmap(dataGridViewImage,New Rectangle(0,Me.DataGridView1.Width,Me.DataGridView1.Height))
    e.Graphics.DrawImage(dataGridViewImage,0)
End Sub

这是打印预览.

Private Sub Button2_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button2.Click

    PrintPreviewDialog2.Document = PrintDocument1
    PrintPreviewDialog2.PrintPreviewControl.Zoom = 1
    PrintPreviewDialog2.ShowDialog()
End Sub

和印刷品……

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click

    PrintDocument1.Print()
End Sub

我试过了
PrintDocument1.PrinterSettings.DefaultPageSettings.Landscape = True

但似乎没有用?

解决方法

您正在为打印机设置DefaultPage设置.
尝试为文档本身设置它:

PrintDocument1.DefaultPageSettings.Landscape = True
PrintDocument1.Print()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读