Hello Alex,
Thank you for writing back.
There is no way to preview the changes without actually applying them to the document. I can suggest adding
your save logic at the end of the
OnShowPrintSettingsDialog method. This way it will be always in sync with the printed or previewed document. Additionally, you may also consider adding the button in the command bar as I suggested in my second post.
In case that does not fit your project and you insist on using the separate button you can apply and save the changes this way:
public
class
MyRadPrintPreviewDialog : RadPrintPreviewDialog
{
Form dialog;
protected
override
void
OnShowPrintSettingsDialog()
{
if
(
this
.Document ==
null
)
{
return
;
}
dialog =
this
.Document.AssociatedObject.GetSettingsDialog(
this
.Document);
RadForm radDialog = dialog
as
RadForm;
RadButton print = radDialog.Controls[
"buttonPrint"
]
as
RadButton;
RadButton saveBtn =
new
RadButton() { Text =
"MyBtn"
};
saveBtn.Parent = radDialog;
saveBtn.Size = print.Size;
saveBtn.Location =
new
Point(print.Location.X - print.Size.Width - 6, print.Location.Y);
saveBtn.Click += saveBtn_Click;
if
(radDialog !=
null
)
{
radDialog.ThemeName =
this
.ThemeName;
}
if
(dialog.ShowDialog() == DialogResult.OK)
{
this
.Document.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.AllPages;
this
.printPreviewControl.InvalidatePreview();
this
.GetType().BaseType.GetMethod(
"UpdatePageCount"
, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(
this
,
new
object
[] { });
}
}
private
void
saveBtn_Click(
object
sender, EventArgs e)
{
typeof
(PrintSettingsDialog).GetMethod(
"ApplySettings"
, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(dialog,
new
object
[] { });
this
.Document.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.AllPages;
this
.printPreviewControl.InvalidatePreview();
this
.GetType().BaseType.GetMethod(
"UpdatePageCount"
, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(
this
,
new
object
[] { });
//Execute your logic for saving the settings
dialog.Close();
}
}
I hope this helps. Please let me know if you need further assistance.
Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this
blog post and share your thoughts.