vs2010 vb 里面的drawline打印一条线,和printpreviewdialog打印预览怎么用的,给个简单的实例代码,谢谢!
解决方案 »
- webbrowser中的超级连接与vb程序能交互吗?有的话,给个方法谢谢!
- 请教SQL Server针对某一列插入时的问题
- 散分,在春节联欢央视调查中调查‘本届春晚你最希望请到哪个韩国歌手?’ 选择 李贞贤 者一律给分!
- 判断数据表中有没有符合条件的记录的方法
- 怎样使VB程序最小化后,停在右边,即在输入法旁边。
- 有谁知道Vertical Menu控件为什么会在显示窗体时出错!?
- 300分征求:installsheild6.3打包的VB程序如何还原?(UP高分)
- 定时器怎么用?(送分喔)
- xlain(lain) 我用的控件 mschart, ado ,listview 这些有问题么?
- 关于VB 调用DLL文件 ?,急急急!!!!!!~~~~~~~~~~~~~~~~~~~~
- 怎么样同时在Access与CSV范围内查找?
- 不太科学的打开文件夹
Dim blackPen As New Pen(Color.Black, 3) ' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100) ' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)
End Subhttp://msdn.microsoft.com/zh-cn/library/f956fzw1.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2
' Declare the dialog.
Friend WithEvents PrintPreviewDialog1 As PrintPreviewDialog' Declare a PrintDocument object named document.
Private WithEvents document As New System.Drawing.Printing.PrintDocument' Initalize the dialog.
Private Sub InitializePrintPreviewDialog() ' Create a new PrintPreviewDialog using constructor.
Me.PrintPreviewDialog1 = New PrintPreviewDialog 'Set the size, location, and name.
Me.PrintPreviewDialog1.ClientSize = New System.Drawing.Size(400, 300)
Me.PrintPreviewDialog1.Location = New System.Drawing.Point(29, 29)
Me.PrintPreviewDialog1.Name = "PrintPreviewDialog1" ' Set the minimum size the dialog can be resized to.
Me.PrintPreviewDialog1.MinimumSize = New System.Drawing.Size(375, 250) ' Set the UseAntiAlias property to true, which will allow the
' operating system to smooth fonts.
Me.PrintPreviewDialog1.UseAntiAlias = True
End SubPrivate Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click If (TreeView1.SelectedNode IsNot Nothing) Then ' Set the PrintDocument object's name to the selectedNode
' object's tag, which in this case contains the
' fully-qualified name of the document. This value will
' show when the dialog reports progress.
document.DocumentName = TreeView1.SelectedNode.Tag
End If ' Set the PrintPreviewDialog.Document property to
' the PrintDocument object selected by the user.
PrintPreviewDialog1.Document = document ' Call the ShowDialog method. This will trigger the document's
' PrintPage event.
PrintPreviewDialog1.ShowDialog()
End SubPrivate Sub document_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles document.PrintPage ' Insert code to render the page here.
' This code will be called when the PrintPreviewDialog.Show
' method is called. ' The following code will render a simple
' message on the document in the dialog.
Dim text As String = "In document_PrintPage method."
Dim printFont As New System.Drawing.Font _
("Arial", 35, System.Drawing.FontStyle.Regular) e.Graphics.DrawString(text, printFont, _
System.Drawing.Brushes.Black, 0, 0)End Sub
http://msdn.microsoft.com/zh-cn/library/system.windows.forms.printpreviewdialog.aspx