Output the PrinterSettings information : Print Preview Dialog « GUI Windows Forms « C# / CSharp Tutorial






using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using System.Drawing.Printing;

public class frmMain : System.Windows.Forms.Form {

    public frmMain() {
        this.Paint += new System.Windows.Forms.PaintEventHandler(this.frmMain_Paint);
    }
    [STAThread]
    static void Main() {
        Application.Run(new frmMain());
    }
    private void frmMain_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
        PrinterSettings pSettings = new PrinterSettings();
        Font printFont = new Font("Arial", 10);

        int nTextPosY = 0;
        int nTextPosX = 5;
        int nHeight = (int)printFont.GetHeight(e.Graphics);

        foreach (string sPtr in PrinterSettings.InstalledPrinters) {
            pSettings.PrinterName = "BadName";
            e.Graphics.DrawString(sPtr, printFont, Brushes.Black, nTextPosX, nTextPosY + 5);
            e.Graphics.DrawString("Can Duplex: " + pSettings.CanDuplex.ToString(),
                printFont, Brushes.Black, nTextPosX + 10, nTextPosY + (5 + nHeight));
            e.Graphics.DrawString("Is Default: " + pSettings.IsDefaultPrinter.ToString(),
                printFont, Brushes.Black, nTextPosX + 10, nTextPosY + (5 + nHeight * 2));
            e.Graphics.DrawString("Is Plotter: " + pSettings.IsPlotter.ToString(),
                printFont, Brushes.Black, nTextPosX + 10, nTextPosY + (5 + nHeight * 3));
            e.Graphics.DrawString("Landscape Angle: " + pSettings.LandscapeAngle.ToString(),
                printFont, Brushes.Black, nTextPosX + 10, nTextPosY + (5 + nHeight * 4));
            e.Graphics.DrawString("Maximum Copies: " + pSettings.MaximumCopies.ToString(),
                printFont, Brushes.Black, nTextPosX + 10, nTextPosY + (5 + nHeight * 5));
            e.Graphics.DrawString("Maximum Page: " + pSettings.MaximumPage.ToString(),
                printFont, Brushes.Black, nTextPosX + 10, nTextPosY + (5 + nHeight * 6));
            e.Graphics.DrawString("Minimum Page: " + pSettings.MinimumPage.ToString(),
                printFont, Brushes.Black, nTextPosX + 10, nTextPosY + (5 + nHeight * 7));
            e.Graphics.DrawString("Supports Color: " + pSettings.SupportsColor.ToString(),
                printFont, Brushes.Black, nTextPosX + 10, nTextPosY + (5 + nHeight * 8));
            nTextPosY = nTextPosY + ((5 + nHeight * 8) + nHeight);
        }
        return;
    }
}








23.50.Print Preview Dialog
23.50.1.Show PrintPreview Dialog before print out a documentShow PrintPreview Dialog before print out a document
23.50.2.Print Preview Dialog for printing text filePrint Preview Dialog for printing text file
23.50.3.Output the PrinterSettings information