This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
/
Form2.vb
52 lines (46 loc) · 1.99 KB
/
Form2.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.LookAndFeel
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Preview
Imports DevExpress.XtraPrinting.Preview
Namespace GridPrinting
Partial Public Class MyPrintDialog
Inherits PrintEditorForm
Public Sub New()
MyBase.New()
End Sub
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
MyBase.OnLoad(e)
Dim comboBox As ImageComboBoxEdit = TryCast(GetType(PrintEditorForm).GetField("icbInstalledPrinters", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.GetField Or System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Instance).GetValue(Me), ImageComboBoxEdit)
If comboBox IsNot Nothing Then
For Each item As Object In comboBox.Properties.Items
If item.ToString() = "Microsoft XPS Document Writer" Then
comboBox.Properties.Items.Remove(item)
Return
End If
Next item
End If
End Sub
End Class
Public Class MyRunner
Inherits PrintDialogRunner
'public override DialogResult Run(PrintDocument document, UserLookAndFeel lookAndFeel, IWin32Window owner) {
'
'}
Public Overrides Function Run(ByVal document As PrintDocument, ByVal lookAndFeel As UserLookAndFeel, ByVal owner As IWin32Window, ByVal flags As PrintDialogAllowFlags) As DialogResult
Using dialog As New MyPrintDialog()
dialog.Document = document
dialog.LookAndFeel.ParentLookAndFeel = lookAndFeel
Return DevExpress.XtraPrinting.Native.DialogRunner.ShowDialog(dialog, owner)
End Using
End Function
End Class
End Namespace