Define the printer to a type of document

Hello,

I need to create a parameter which shows me the printers are installed and I pick one for each type of document (For example: Invoices to Epson ESC/PR, Orders to Samsung 2145, etc.).

How I can get the printers that are installed on the system?

Thanks

Alberto Ferraz

Parents
  • I found an example for doing this. You can automatically bind a combo box control to the printer collection by adding the following namespace to your xaml:

    xmlns:Printing="clr-namespace:System.Drawing.Printing;assembly=System.Drawing"

    and then adding the System.Drawing assembly to your project references.

    You can then define the combobox with:

    <ComboBox x:Name="prtcomboBox" HorizontalAlignment="Left" Margin="89,119,0,0" VerticalAlignment="Top" Width="301" Height="21" ItemsSource="{x:Static Printing:PrinterSettings.InstalledPrinters}" SelectionChanged="prtcomboBox_SelectionChanged" />

    Everytime a new printer is selected the prtcomboBox_SelectionChanged event will be triggered so you can get the selected printer name.

    method-id prtcomboBox_SelectionChanged.
          procedure division using by value sender as object e as type System.Windows.Controls.SelectionChangedEventArgs.
              set textBox1::Text to prtcomboBox::SelectedValue
          end method.

Reply
  • I found an example for doing this. You can automatically bind a combo box control to the printer collection by adding the following namespace to your xaml:

    xmlns:Printing="clr-namespace:System.Drawing.Printing;assembly=System.Drawing"

    and then adding the System.Drawing assembly to your project references.

    You can then define the combobox with:

    <ComboBox x:Name="prtcomboBox" HorizontalAlignment="Left" Margin="89,119,0,0" VerticalAlignment="Top" Width="301" Height="21" ItemsSource="{x:Static Printing:PrinterSettings.InstalledPrinters}" SelectionChanged="prtcomboBox_SelectionChanged" />

    Everytime a new printer is selected the prtcomboBox_SelectionChanged event will be triggered so you can get the selected printer name.

    method-id prtcomboBox_SelectionChanged.
          procedure division using by value sender as object e as type System.Windows.Controls.SelectionChangedEventArgs.
              set textBox1::Text to prtcomboBox::SelectedValue
          end method.

Children
No Data