dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


advertisement
 

Tip: Copy the WebBrowser Control's Text in HTML Format

Explore how to copy the HTML document of the WebBrowser control in HTML format.


advertisement

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


To copy the HTML document of the WebBrowser control in HTML format, you need to use the IHTMLDocument2 object of the MSHTML class.

For this, you need to add a reference to Microsoft.mshtml assembly which can be found in C:\Program Files\Microsoft.NET\Primary Interop Assemblies folder. Then write the following code in a button click event (btnCopyTextAsHTML in my example).

private void btnCopyTextAsHTML _Click(object sender, EventArgs e) 
{ 
   HtmlDocument document = myWebBrowser.Document; 
   if (document != null) 
   { 
     document.ExecCommand("SelectAll", false, null); 
     IHTMLDocument2 htmlDocument = document.DomDocument as IHTMLDocument2;      (htmlDocument.selection.createRange() as IHTMLTxtRange).execCommand("Copy", false, null); 
  } 
}


 

Visit the DevX Tip Bank

 



   
Srinath M. S. says: "I would love to leave a footprint in this flat world."
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
By using this site, you agree to the Privacy Policy
Thanks for your registration, follow us on our social networks to keep up-to-date