成都网站建设设计

将想法与焦点和您一起共享

包含vbnet打印控件使用的词条

vb.net如何实现打印DataGridView1里的内容,求源码

使用 PrintDocument 控件的 Print() 方法可以打印指定对象中的内容,参考代码如下:

成都创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于成都网站设计、成都网站建设、嘉荫网络推广、小程序开发、嘉荫网络营销、嘉荫企业策划、嘉荫品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;成都创新互联公司为所有大学生创业者提供嘉荫建站搭建服务,24小时服务热线:18982081108,官方网址:www.cdcxhl.com

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添加打印控件的用法

txt文件:

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 打印功能

可以把数据导出到EXCEL,然后使用EXCEL进一步处理后使用。

也可以做成vb报表(VB自带有)。

先设置报表格式,打印时向报表传递数据就可以了。

VS2005如何用VB.NET代码实现打印功能

有个PrintDocument控件,可以实现打印。。。

MSDN原话:

使用 PrintDocument 组件

涉及 PrintDocument 组件的两种主要情况是:

简单的打印作业,如打印单个文本文件。在这种情况下,应将 PrintDocument 组件添加到 Windows 窗体,然后在 PrintPage 事件处理程序中添加打印文件的编程逻辑。 该编程逻辑应以使用 Print 方法打印文档结束。

此方法向打印机发送一个 Graphics 对象,该对象包含在 PrintPageEventArgs 类的 Graphics 属性中。

有关如何使用 PrintDocument 组件打印文本文档的示例,请参见

如何:打印 Windows 窗体中的多页文本文件。

更为复杂的打印作业,如想要重新使用已编写的打印逻辑的情况。

在这种情况下,应从 PrintDocument 组件派生一个新组件,并重写

(请参见 Visual Basic 的 重写或 C# 的 重写) PrintPage 事件。

将 PrintDocument 组件添加到窗体后,它出现在 Windows 窗体设计器底部的栏中

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打印问题(有滚动条控件的内容怎么全部打印)

参考:

把执行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


标题名称:包含vbnet打印控件使用的词条
标题来源:http://chengdu.cdxwcx.cn/article/docpshs.html