[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1063
  • Last Modified:

Disable form when web browser use print command.

Good Day,
     I try to use webBrowser1.Document.ExecCommand("Print", true, null) to print the web browser. However the form was not disable, this make user can click the print button again which prompt-up the print dialog box again. How can I make the form disable and enable again if user click print or cancel.
private void toolStripButton1_Click(object sender, EventArgs e)
{
    webBrowser1.Document.ExecCommand("Print", true, null);
}

Open in new window

web-browser.png
0
kinchoong
Asked:
kinchoong
  • 5
  • 4
1 Solution
 
Bob LearnedCommented:
Did you try this?

private void toolStripButton1_Click(object sender, EventArgs e)
{
    this.Enabled = false;
    webBrowser1.Document.ExecCommand("Print", true, null);
    this.Enabled = true;
}
0
 
kinchoongAuthor Commented:
Thanks for the reply.

     Is seen like didn't because it disable the web browser, call the print dialog box and then enable back the web browser. Need to find a way to disable the web browser while the print dialog box is open and enable back while the print dialog box is close.
0
 
Bob LearnedCommented:
I don't understand what you are describing...you want to disable the browser, but not disable the browser...
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
kinchoongAuthor Commented:
Sorry for confusing you.

In order to prevent the user click on the print button in the web browser. I have to disable the web browser when the print dialog box is appear, when the user finished he business with the print dialog box, I have to enable back the web browser.

The code you give me will disable the web browser and then prompt up the dialog box and then enable back the web browser in a second only, so the user can click on the print button on the web browser again to prompt up the second print dialog box.

I hope I can make you understand what I want. Beside that, thank you for you time.
0
 
Bob LearnedCommented:
Aah, I don't know of any event that occurs when you click on a dialog button.  That doesn't mean that one doesn't exist, though, I just don't know about one.
0
 
kinchoongAuthor Commented:
Thanks for your time.

     I read some article saying that maybe I need to edit the print template in the web browser. It too complex for me and I don't understand what it is. @@. Never mind I think it is OK to leave it like that for now. Thanks again for your attention, I know all you guys are very busy with your stuff.
0
 
Bob LearnedCommented:
I participate in questions like this, when I don't have an answer, so that I might be able to find a solution for you, and learn something for me at the same time.  It might help if you could show me that article that you referenced (if you can find it again).
0
 
kinchoongAuthor Commented:
Good Day The Learned One,

     Sorry, I can't find back the article. However, I did remember it does use some visual basic library. Anyway, if you want to know more about print template, you can click on the link below:

     http://msdn.microsoft.com/en-us/library/aa753280(VS.85).aspx

     Beside that, I think I found my solution in the link below. However, I don't have a visual studio installed in my computer, so I can't test it out. Maybe you can help to test it?

    http://www.c-sharpcorner.com/UploadFile/kapilsoni88/WebBrowser_In_DotNet_203162009043331AM/WebBrowser_In_DotNet_2.aspx

http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=43187

     Let's learn together!
0
 
kinchoongAuthor Commented:
I think the following code will solve the problem:

private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
    WebBrowser web_print = GetCurrentWebBrowser();
    web_print.ShowPrintDialog();
}

rather than using:

private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
    webBrowser1.Document.ExecCommand("Print", true, null);
}
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now