PropertyGrid 中已安装的打印机列表



在我的应用程序中,我使用PropertyGrid。
大多数值都是在枚举中预定义的,因此属性网格让我自动选择(在组合框中)在它们之间进行选择。

其中,我必须选择应用程序在哪台打印机上打印。
这些数据不能存储在 Enum 上,因为它几乎在每台机器上都不同。

这里有一种方法可以在属性网格中获取已安装打印机的类似组合框的列表吗?
当然,我知道如何使用已安装的打印机名称创建字符串列表。

该示例向您展示如何通过 ComBobox 显示所有已安装的打印机,您可以对其进行编辑以在属性 Grid 上显示它:

Dim InstalledPrinters As String
' Find all printers installed
For Each InstalledPrinters In _
    System.Drawing.Printing.PrinterSettings.InstalledPrinters
    Me.Combobox1.Items.Add(InstalledPrinters)
Next InstalledPrinters
' Set the combo to the first printer in the list
Me.Combobox1.SelectedIndex = 0

最新更新