关于vb.net添加打印控件的用法
txt文件:
10年的道县网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站的优势是能够根据用户设备显示端的尺寸不同,自动调整道县建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“道县网站设计”,“道县网站推广”以来,每个客户项目都认真落实执行。
procedure TForm1.Button1Click(Sender: TObject);
var
MyFile: TextFile;
SourceFile:TextFile;
Tmp:String;
begin
AssignPrn(MyFile);
AssignFile(SourceFile,'FilePath');
Reset(SourceFile);
Rewrite(MyFile);
Readln(SourceFile,Tmp);
While Not EOF(SourceFile) do
Begin
Writeln(MyFile, Tmp);
Readln(SourceFile,Tmp);
System.CloseFile(MyFile);
end;
图形文件需要TPrinter.canvas来打印了,
VB.NET打印问题(有滚动条控件的内容怎么全部打印)
参考:
把执行SQL语句后得到的记录集逐条(含字段名)显示在LISTVIEW控件中
'----------------------------------------------------------------
Public Sub ListUpdate(ByRef rs As Recordset, ByRef lv As ListView)
Dim head As ColumnHeader, Item As ListItem
Dim i As Integer, j As Integer
Dim lvWidth As Integer
lvWidth = lv.Width
'初始化LISTVIEW的某些属性
lv.View = lvwReport
lv.GridLines = True
lv.FullRowSelect = True
lv.ListItems.Clear
lv.ColumnHeaders.Clear
For i = 0 To rs.Fields.Count - 1
Set head = lv.ColumnHeaders.Add
head.Text = rs.Fields(i).Name
head.Width = lvWidth / rs.Fields.Count
Next
For j = 1 To PERPAGE
If rs.EOF Then Exit For
Set Item = lv.ListItems.Add
Item.Text = "" rs.Fields(0).Value
For i = 1 To rs.Fields.Count - 1
Item.SubItems(i) = "" rs.Fields(i).Value
Next
rs.MoveNext
Next
End Sub
' 打印
Public Sub PrintRecordset(ByRef recRecordset As Recordset, ByVal strType As String)
Dim LeftMargin As Integer
Dim HeadTopPosition As Integer
Dim FieldNum As Integer
Dim PageCounter As Integer
Dim MyRecordset As ADODB.Recordset
Const FooterTopPosition = 24
Set MyRecordset = recRecordset
PageCounter = 1
' 设 置Printer 对 象 坐 标 的 度 量 单 位 为 厘 米
Printer.ScaleMode = vbCentimeters
LeftMargin = 1.5
HeadTopPosition = 2
' 定 义 打 印 页 左 上 角 的X 坐 标 和Y 坐 标, 通 过 改 变ScaleLeft 和ScaleTop 的 值, 可 改 变 打 印 页 的 左 边 距 和 上 边 距
Printer.ScaleLeft = -LeftMargin
Printer.ScaleTop = -HeadTopPosition
Printer.Font.Name = "Times New Roman"
Printer.Font.Size = 12
Printer.Print "音像店顾客管理系统"
Printer.Print strType
Printer.Print ""
If MyRecordset.EOF And MyRecordset.BOF Then
MsgBox "No Record At Presend!", vbCritical And vbOKOnly, "Print Error"
Exit Sub
End If
MyRecordset.MoveFirst
Do Until Printer.CurrentY FooterTopPosition
'Print the fields of the recordset in sequence
For FieldNum = 0 To MyRecordset.Fields.Count - 1
Printer.Print MyRecordset.Fields(FieldNum).Name _
": " _
MyRecordset.Fields(FieldNum).Value
If Printer.CurrentY FooterTopPosition Then
Printer.CurrentX = 8
Printer.Print "Page: " PageCounter
' 创 建 多 页 文 档
Printer.NewPage
PageCounter = PageCounter + 1
End If
Next FieldNum
MyRecordset.MoveNext
If MyRecordset.EOF Then Exit Do
' 在 记 录 之 间 空 一 行
Printer.Print ""
Loop
'Print the Page number as a footer
Printer.CurrentX = 8
Printer.CurrentY = FooterTopPosition
Printer.Print "Page: " PageCounter
' 将 输 出 送 到 打 印 机
Printer.EndDoc
End Sub
VB.NET 打印问题。
先拖过来控件PrintDocument1,然后双击PrintDocument1,在它的PrintPage事件中加入代码如下:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
dim a as String
a="abcd"
Dim mypen As Pen = New Pen(Color.Blue, 2)
e.Graphics.DrawString(a, New Font("宋体", 20), New Pen(Color.Black, 1).Brush, 30, 30)
End Sub
调用下面语句可直接用默认打印机打印出来:
PrintDocument1.Print()
VB.NET怎么实现打印功能啊 呜呜(
利用 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" '打印的内容
e.Graphics.DrawString(s, stringFont, Brushes.AliceBlue, rectDraw, strFormat)
End Sub
vb.net如何实现打印DataGridView1里的内容,求源码
使用 PrintDocument 控件的 Print() 方法可以打印指定对象中的内容,参考代码如下:
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
VB.NET打印编程问题,打印机为激光打印机。
打印做得不多,以前做套打时发现,每台打印机定位都不一样,于是每台机子都加了个偏移设置
我的做法在白纸上打上一标尺,和一个上下边距为2CM的交叉点,然后用标尺量这2CM的偏移,设置完后,在这台打印机打印时,就给纸张加个偏移量,打印就正常了。可能你的原因和我一样。
另外也想问你一下,你这个条码是用什么打的。早先,我用立象的条码打印机打不干胶,很简单,激光打没用过,可能下次我也要用条码打印,我也用VB.net。求教.
分享文章:vbnet打印控件编程 vb打印代码
本文来源:http://scgulin.cn/article/hipdsd.html