C# Controls: How do I activate the PrintDialog from a Toolstrip item?
Q: Whenever I show the PrintDialog from a Toolstrip button, using the UseExDialog property, I have to click the PrintDialog twice, before it gets activated, how can I fix this?
A: You should make use of a Delegate to handle the displaying of the PrintDialog, here is an example :
Code:
delegate DialogResult ShowThePrintDialog(); //Create Delegate
private void toolStripButton1_Click(object sender, EventArgs e)
{
ShowThePrintDialog printD = new ShowThePrintDialog(printDialog1.ShowDialog); //What the Delegate Must Do
this.BeginInvoke(printD); //Start The Delegate
}
This is of course assumed that you have a PrintDialog and a Toolstrip ( with at least one button ) on the form, using their default names.
I have added 2 attachments.
The one Attachment ( WrongResult.zip ), demonstrates the behaviour of the PrintDialog, when using the UseExDialog property set to true. When you run the sample, you will see that you have to click the PrintDialog twice, as it is not automatically activated.
The second attachment, demonstrates how to overcome this issue.
Last edited by HanneSThEGreaT; May 19th, 2010 at 07:02 AM.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.