使用 PrintDocument 控件的 Print() 方法可以打印指定對象中的內(nèi)容,參考代碼如下:
在雷州等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供做網(wǎng)站、網(wǎng)站制作 網(wǎng)站設(shè)計制作按需求定制開發(fā),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計,全網(wǎng)整合營銷推廣,成都外貿(mào)網(wǎng)站建設(shè)公司,雷州網(wǎng)站建設(shè)費用合理。
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
PrintDocument1.Print()
End?Sub
Private?Sub?PrintDocument1_PrintPage(ByVal?sender?As?System.Object,?ByVal?e?As?System.Drawing.Printing.PrintPageEventArgs)?Handles?PrintDocument1.PrintPage
Dim?bm?As?New?Bitmap(Me.DataGridView1.Width,?Me.DataGridView1.Height)
DataGridView1.DrawToBitmap(bm,?New?Rectangle(0,?0,?Me.DataGridView1.Width,?Me.DataGridView1.Height))
e.Graphics.DrawImage(bm,?0,?0)
End?Sub
用PrintForm控件,在Visual Basic PowerPacks項目列表中vb2008 SP1以后版本就有了,下面是代碼
Imports System.Drawing.Printing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'先設(shè)置打印頁面的頁邊距
With Me.PrintForm1
Dim myMargins As New Margins '頁邊距設(shè)置信息是存放在這個Margins類型的對象中的
With myMargins '分別設(shè)置上下左右邊距,
.Left = 12
.Right = 12
.Top = 12
.Bottom = 12
End With
.PrinterSettings.DefaultPageSettings.Margins = myMargins '把myMargins對象賦給PrintForm1的設(shè)置屬性
End With
Me.Button1.Visible = False '這個是在打印的時候隱藏打印按鈕
Me.PrintForm1.Form = Me '設(shè)置要打印的窗體
Me.PrintForm1.Print() '調(diào)用打印窗體方法
Me.Button1.Visible = True '再把隱藏的打印按鈕顯示出來
End Sub
可以把數(shù)據(jù)導(dǎo)出到EXCEL,然后使用EXCEL進(jìn)一步處理后使用。
也可以做成vb報表(VB自帶有)。
先設(shè)置報表格式,打印時向報表傳遞數(shù)據(jù)就可以了。
可以將打印機(jī)默認(rèn)打印設(shè)置改為黑白打印,如果打印對象是RGB配色,打印機(jī)驅(qū)動轉(zhuǎn)換為CMYK顏色時,黑色都是由彩色墨水組成的
2.可以試一下圖片從一個標(biāo)準(zhǔn)灰度圖片格式化而來,這樣圖片自身只有黑白色,也許可以
使用jquery.print插件
我用得jQuery.print, version 1.3.2。
頁面上調(diào)用代碼如下:PrintArea就是你panel的ID....
script src="~/Scripts/jQuery.print.js"/script
script
function printarea() {
$("#PrintArea").print({
globalStyles: true,
mediaPrint: false,
stylesheet: null,
noPrintSelector: ".no-print",
iframe: true,
append: null,
prepend: null,
manuallyCopyFormValues: true,
deferred: $.Deferred()
});
}
/script
a class="btn btn-success" onclick="printarea()"打印/a
利用 printdocument控件
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
PrintDocument1.Print()
End Sub
Private Sub PrintDocument1_PrintPage(sender As System.Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim stringFont As New Font("Arial", 16)
Dim rectDraw As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)
Dim strFormat As New StringFormat
Dim s As String
s = "print word" '打印的內(nèi)容
e.Graphics.DrawString(s, stringFont, Brushes.AliceBlue, rectDraw, strFormat)
End Sub
本文名稱:vb.net打印內(nèi)容 vbs打印文件
本文URL:http://www.chinadenli.net/article36/hpgcsg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計、移動網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、微信小程序、服務(wù)器托管、網(wǎng)頁設(shè)計公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)