我打开一个PrintDialog框,然后用它设置打印信息;
DialogResult result = PrintDialog.ShowDialog();
现在,我想在点击“应用”按钮时保存printDialog的信息。当我再次打开printDialog框时,显然设置的设置不应该改变。
答案 0 :(得分:0)
在某个文件中存储该信息,下次打开您的应用程序时,检查该文件是否包含所需信息,如果该信息包含该信息,则在您的应用程序中使用该信息,否则从用户处获取该信息
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();
}
}