Printer settings: Display the list of valid paper sizes
Submitted by donbermoy on Saturday, June 28, 2014 - 14:28.
      
            This tutorial will teach you on how to get and display the list of valid paper sizes of the printer. I already have this tutorial on how to display the list of printers installed in the computer.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application in C# for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application and name your project as Printer Settings.
2. Next, add a Button named button1 to get all the valid paper sizes of the printer, and listbox named listBox1 to display there the paper sizes. You must design your interface like this:
 3. In your button1 to display all the list of valid paper sizes to be printed, put this code below.
We have declared a foreach loop statment to get all the the installed printers. Inside the loop, we declare a printer variable to call the printer settings. And the printer variable holds the printerName to get the settings of a particular printer. Then, we have created an If statement for the validation of printers. Inside of it is the creation again of a foreach loop that gets the paper sizes of the printer and will be added and diplayed in the listBox.
Output:
3. In your button1 to display all the list of valid paper sizes to be printed, put this code below.
We have declared a foreach loop statment to get all the the installed printers. Inside the loop, we declare a printer variable to call the printer settings. And the printer variable holds the printerName to get the settings of a particular printer. Then, we have created an If statement for the validation of printers. Inside of it is the creation again of a foreach loop that gets the paper sizes of the printer and will be added and diplayed in the listBox.
Output:
 For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
      
             3. In your button1 to display all the list of valid paper sizes to be printed, put this code below.
3. In your button1 to display all the list of valid paper sizes to be printed, put this code below.
- private void button1_Click(object sender, EventArgs e)
- {
- // get all the installed printers
- foreach (string printerName in PrinterSettings.InstalledPrinters)
- {
- //call the printer settings
- printer.PrinterName = printerName; //get the settings of a particular printer
- // if there is a printer
- if (printer.IsValid)
- {
- //get all the valid paper sizes for printer
- foreach (PaperSize size in printer.PaperSizes)
- {
- // get the size to the printer
- if (Enum.IsDefined(size.Kind.GetType(), size.Kind))
- {
- // added the paper sizes of the printer to the listbox
- listBox1.Items.Add( size);
- }
- }
- }
- }
- }
 For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware 
              