Reputation: 43
I'm using C# 4.0 and MsCharts within Visual Studio 2010. When I execute
MyPlotChart.Printing.PrintPreview();
(See http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.printingmanager.printpreview ) It works as intended, but the Print Preview dialog shows the default icon. Is there a way to use my own icon, please? Like what I would do with PrintPreviewDialog.Icon (see http://msdn.microsoft.com/en-us/library/system.windows.forms.printpreviewdialog.icon.aspx )
Thanks.
Upvotes: 1
Views: 1464
Reputation: 1
Long time later but that help me to find the solution :
(printPreviewToolStripMenuItem as Form).Icon = Properties.Resources.MonIcon;
Upvotes: 0
Reputation: 2154
My answer, just set the icon property:
public DialogResult ShowPrintPreview(float zoomFactor = 1F)
{
_nPageNumber = 1;
_bPrintSel = false;
_previewDlg.PrintPreviewControl.Zoom = zoomFactor;
_previewDlg.Size = new Size(1200, 800);
_previewDlg.StartPosition = FormStartPosition.CenterScreen;
_previewDlg.Icon = **PrintPreviewIcon**;
return _previewDlg.ShowDialog(this);
}
public Icon PrintPreviewIcon { get; set; }
Upvotes: 0
Reputation: 43
In the end I wrote a hack for this. I added a forms.timer that I enable right before calling PrintPreview(). Then I locate the form in Application.OpenForms and set the icon.
private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)
{
if (PrintPreviewIcon != null)
{
PrintPreviewTimer.Enabled = true;
}
PlotChart.Printing.PrintPreview();
}
private void PrintPreviewTimer_Tick(object sender, EventArgs e)
{
foreach (Form f in Application.OpenForms)
{
if (f is PrintPreviewDialog)
{
f.Icon = PrintPreviewIcon;
PrintPreviewTimer.Enabled = false;
}
}
}
Upvotes: 1