vb.net打印文本 vb打印窗體內(nèi)容

vb.net Document_PrintPage打印多行文本

比如:

10年品牌的成都網(wǎng)站建設(shè)公司,上1000+企業(yè)網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn).價(jià)格合理,可準(zhǔn)確把握網(wǎng)頁(yè)設(shè)計(jì)訴求.提供定制網(wǎng)站建設(shè)、商城網(wǎng)站建設(shè)、小程序定制開(kāi)發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等服務(wù),我們?cè)O(shè)計(jì)的作品屢獲殊榮,是您值得信賴(lài)的專(zhuān)業(yè)的建站公司。

Private Sub Document_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)

e.Graphics.DrawString(str0, New Font("Arial", 14, FontStyle.Regular), Brushes.Black, 50, 50)

e.Graphics.DrawString(A1, New Font("Arial", 10, FontStyle.Regular), Brushes.Black,50, 100)

e.Graphics.DrawString(A2, New Font("Arial", 10, FontStyle.Regular), Brushes.Black, 300,100)

e.Graphics.DrawString(A3, New Font("Arial", 10, FontStyle.Regular), Brushes.Black, 800,100)

也就是分次用不同坐標(biāo)和不同的字體來(lái)打印各變量。畫(huà)線用:

e.Graphics.DrawLine(BlackPen, x1, y1, x2, y2)。

具體坐標(biāo)數(shù)值自己用尺量出,再換算。

怎樣用熱敏打印機(jī)把vb.net窗體內(nèi)文本框內(nèi)容打印出來(lái)

用PrintForm控件,在Visual Basic PowerPacks項(xiàng)目列表中vb2008 SP1以后版本就有了,下面是代碼

Imports System.Drawing.Printing

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

'先設(shè)置打印頁(yè)面的頁(yè)邊距

With Me.PrintForm1

Dim myMargins As New Margins '頁(yè)邊距設(shè)置信息是存放在這個(gè)Margins類(lèi)型的對(duì)象中的

With myMargins '分別設(shè)置上下左右邊距,

.Left = 12

.Right = 12

.Top = 12

.Bottom = 12

End With

.PrinterSettings.DefaultPageSettings.Margins = myMargins '把myMargins對(duì)象賦給PrintForm1的設(shè)置屬性

End With

Me.Button1.Visible = False '這個(gè)是在打印的時(shí)候隱藏打印按鈕

Me.PrintForm1.Form = Me '設(shè)置要打印的窗體

Me.PrintForm1.Print() '調(diào)用打印窗體方法

Me.Button1.Visible = True '再把隱藏的打印按鈕顯示出來(lái)

End Sub

VS2005如何用VB.NET代碼實(shí)現(xiàn)打印功能

有個(gè)PrintDocument控件,可以實(shí)現(xiàn)打印。。。

MSDN原話:

使用 PrintDocument 組件

涉及 PrintDocument 組件的兩種主要情況是:

簡(jiǎn)單的打印作業(yè),如打印單個(gè)文本文件。在這種情況下,應(yīng)將 PrintDocument 組件添加到 Windows 窗體,然后在 PrintPage 事件處理程序中添加打印文件的編程邏輯。 該編程邏輯應(yīng)以使用 Print 方法打印文檔結(jié)束。

此方法向打印機(jī)發(fā)送一個(gè) Graphics 對(duì)象,該對(duì)象包含在 PrintPageEventArgs 類(lèi)的 Graphics 屬性中。

有關(guān)如何使用 PrintDocument 組件打印文本文檔的示例,請(qǐng)參見(jiàn)

如何:打印 Windows 窗體中的多頁(yè)文本文件。

更為復(fù)雜的打印作業(yè),如想要重新使用已編寫(xiě)的打印邏輯的情況。

在這種情況下,應(yīng)從 PrintDocument 組件派生一個(gè)新組件,并重寫(xiě)

(請(qǐng)參見(jiàn) Visual Basic 的 重寫(xiě)或 C# 的 重寫(xiě)) PrintPage 事件。

將 PrintDocument 組件添加到窗體后,它出現(xiàn)在 Windows 窗體設(shè)計(jì)器底部的欄中

VB.NET如何能將文本框中的內(nèi)容原樣打印

Imports?System.Drawing.Printing

Public?Class?Form1

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

Try

Dim?PDoc?As?New?PrintDocument

AddHandler?PDoc.PrintPage,?AddressOf?Me.PText

PDoc.Print()

Catch?ex?As?Exception

MessageBox.Show("error",?ex.ToString)

End?Try

End?Sub

Private?Sub?PText(ByVal?sender?As?Object,?ByVal?e?As?PrintPageEventArgs)

e.Graphics.DrawString(TextBox1.Text,?New?Font("Arial",?11,?FontStyle.Regular),?Brushes.Black,?120,?120)

e.HasMorePages?=?False

End?Sub

End?Class

新聞標(biāo)題:vb.net打印文本 vb打印窗體內(nèi)容
網(wǎng)站URL:http://muchs.cn/article14/doscede.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)關(guān)鍵詞優(yōu)化、網(wǎng)站建設(shè)、動(dòng)態(tài)網(wǎng)站電子商務(wù)、網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)