首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

VB.NET里如何改!

2012-03-02 
VB.NET里怎么改!?Printer.CurrentXx+3打印的起始x坐标Printer.FontSize16应该是打印字的大小这是VB2.0时

VB.NET里怎么改!?
Printer.CurrentX   =   x   +   3       打印的起始x坐标
Printer.FontSize   =   16               应该是打印字的大小
这是VB2.0时候的程序....
现在要在VB.NET改过来...
怎么改......查了下MSDN   说用PrintDocumen组件
代替Printer,但我不会用组件Printer对象...谁教教我
新手......

[解决办法]
给你个我写的例子,其实打印方面东西太多,建议楼主详细看看,很简单的
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim mylinesperpage As Single = 0
Dim myypos As Single = 0
Dim mycount As Integer = 0
Dim myleftmargin As Single = e.MarginBounds.Left
Dim mytopmargin As Single = e.MarginBounds.Top
Dim myline As String
mylinesperpage = e.MarginBounds.Height / Me.Font.GetHeight(e.Graphics)
Dim myreader = New System.IO.StreamReader(myfilename, System.Text.Encoding.Default)

While (mycount < mylinesperpage)
myline = myreader.readline
If myline Is Nothing Then
Exit While
End If
myypos = mytopmargin + mycount * Font.GetHeight(e.Graphics)
e.Graphics.DrawString(myline, Font, Brushes.Black, myleftmargin, myypos, New StringFormat)
mycount += 1
If Not myline Is Nothing Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
End While

End Sub
[解决办法]
同时打印还需要vb.net自带的几个控件配合,PrintDialog1,PrintPreviewDialog1等...

热点排行