2

I open a PrintDialog box then set print info on that using this;

 DialogResult result = PrintDialog.ShowDialog();

Now, I want to save infomation of the printDialog when I click 'Apply' button. And when I open printDialog box again, peviously set settings should not change.

Kopika
  • 122
  • 15
Do Thanh Tung
  • 1,223
  • 2
  • 19
  • 30
  • The PrinterSettings class has the [Serializable] attribute. So you can serialize it to preserve the settings. Or just plain store the PrintDialog.PrinterSettings property in a variable. – Hans Passant Oct 05 '15 at 10:59

1 Answers1

0

STore that information in some file and next time when you open your application, check if the file contains required information, if it contains that info then use that information in your application else get it from the user

string filename = "file.txt";
        PrintDialog pd = new PrintDialog();
        if (File.ReadAllText(filename).Count() > 0)
        {
            //printer setting should be applied using this file
            //read the filename line by line and apply the setting
            pd.PrinterSettings.PrinterName=""; //line 1 of file..
            .
            .
            .
            .
        }
        else
        {

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                StreamWriter sw = new StreamWriter(filename);
                sw.WriteLine(pd.PrinterSettings.PrinterName);

                .
                .
                .
                .
                sw.Close();
            }
        }
amit dayama
  • 3,246
  • 2
  • 17
  • 28