C# Controls: How do I activate the PrintDialog from a Toolstrip item?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: C# Controls: How do I activate the PrintDialog from a Toolstrip item?

  1. #1
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,091

    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.

    Q: What is a Delegate?

    A: More Information

    Q: What does BeginInvoke do?

    A: Control.BeginInvoke

    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.
    Attached Files Attached Files
    Last edited by HanneSThEGreaT; May 19th, 2010 at 07:02 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center