Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8329327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:44:43+00:00 2026-06-09T01:44:43+00:00

I am creating a new Web Browser control in my windows forms project to

  • 0

I am creating a new Web Browser control in my windows forms project to print some formatted HTML. The user does not need to see the control since it is simply printing a specially formatted version of the page that they are on.

This is the process of printing I am currently using.

    internal void PrintQuestion(SessionPart SessionPart)
    {
        WebBrowser wbForPrinting = new WebBrowser(); //<-- Undisposed local
        wbForPrinting.Parent = this;
        wbForPrinting.DocumentCompleted += wbForPrinting_DocumentCompleted;
        wbForPrinting.DocumentText = string.Format(DOCUMENT_HTML, SessionPart.Session.Course.Product.Name, HtmlFormatter.GetPrintableQuestion(SessionPart));
    }

    void wbForPrinting_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        // Print the document now that it is fully loaded.
        ((WebBrowser)sender).ShowPrintPreviewDialog();
    }

I can not dispose of the WebBrowser right after the show print preview dialog because that would destroy the object I am attempting to print. There does not seem to be an event or way of determining that the user is done with the WebBrowser (either by finishing the print, or canceling the preview). This is the last piece of this project and my time is running out, I do not want to leave an undisposed local.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:44:45+00:00Added an answer on June 9, 2026 at 1:44 am

    have you tried this

    void wbForPrinting_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        // Print the document now that it is fully loaded.
        ((WebBrowser)sender).ShowPrintPreviewDialog();
        // Dispose the WebBrowser now that the task is complete. 
        ((WebBrowser)sender).Dispose();
    }
    

    Printing with Web Browser Control and Disposing afterwards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a user control that will create a series of html elements
Just working on a image uploader/resizer in my asp.net 4 web forms project. Does
When creating a new item - Web Form using Master Page I get a
We're creating a new consumer/public-facing ASP.Net web app. There are two concerns: --Use cookie
I am thinking about creating my new asp.net mvc web application compatible with native
To preface I am new to web development. I am looking at creating a
I'm just new to creating and launching web sites and i've hit a stumbling
I'm new to PHP and I am currently creating a PHP web application for
when i am creating new android project from visual studio 2010 it gives the
When I'm creating new project with GWT plug in it creates a skeleton project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.