收藏。
1.在全局代码定义对象
Public _MyRDL As C1.Win.C1Preview.C1PrintPreviewControl
Public _MyDoc As C1.C1Preview.C1PrintDocument
2.新建窗体:frmPrintViewer,添加一个 Panel1 空间,Fill
AfterLoad写入代码:
_MyRDL = New C1.Win.C1Preview.C1PrintPreviewControl
_MyRDL.Document = _MyDoc
Dim p As WinForm.Panel = e.Form.controls("Panel1")
_MyRDL.Dock = 5
p.BaseControl.Controls.Add(_MyRDL)
_MyDoc.Generate() '这句替代 doc.Preview() '预览
_MyRDL.Toolbars.File.Visible = False
AfterClose写入代码:
_MyDoc.Dispose()
_MyDoc = Nothing
_MyRDL.Dispose()
_MyRDL = Nothing
3.在需要打印的按钮写入代码:
Dim Doc As new PrintDoc
Dim rt As New prt.RenderText '定义一个文本对象
rt.Text = "haohaohaohoassskankanxxxxxxx" '设置文本对象的内容
Doc.Body.Children.Add(rt)
_MyDoc = Doc
forms("frmPrintViewer").Show
[此贴子已经被作者于2019/1/17 16:10:15编辑过]