gpt4 book ai didi

vb.net - 横向模式打印 vb.net

转载 作者:行者123 更新时间:2023-12-03 00:42:30 24 4
gpt4 key购买 nike

我设法打印数据 GridView 的内容,但它不适合纵向模式。我想以横向模式打印就可以了。

我的数据集有这段代码来填充数据 GridView 。

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, 0, Me.DataGridView1.Width, Me.DataGridView1.Height))
e.Graphics.DrawImage(dataGridViewImage, 0, 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()

关于vb.net - 横向模式打印 vb.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13550067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com