Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2004

Tip: Looking for answers? Try searching our database.

Viewin HTML in Winform application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Serge - 23 Jun 2004 22:55 GMT
I am looking for a way to view HTML in Winform application. Does anyone know if there is something like a browser control that I could use to render the HTML?

Thanks,
Serge.
Sahil Malik - 23 Jun 2004 23:16 GMT
You need this
http://www.windowsforms.net/TrackViews.aspx?ID=186&Type=Samples&Redir=http%3a%2f
%2fwindowsforms.net%2fdownloads%2fgdn%2fXhtml2Rtf.zip


It's XHTML, not HTML, but hey close enough huh?

Signature

- Sahil Malik
Independent Consultant
You can reach me thru my blog - http://dotnetjunkies.com/WebLog/sahilmalik/

> I am looking for a way to view HTML in Winform application. Does anyone know if there is something like a browser control that I could use to render
the HTML?

> Thanks,
> Serge.
Serge - 24 Jun 2004 00:03 GMT
Thanks for suggestions,
It seems that this sample creats the .rtf format, what I am looking is to be able to display an HTML page that is an aggregate of several HTML documents that are dynamically contcatenated into a one page (as if it is some kind of a report). When user selects one of the buttons on a panel on the left, the panel on the right that hosts the HTML page should be able to scroll to the correct portion of the HTML report. It seems that I might be able to do this using the Browser ActiveX control.

Serge.

> You need this
> http://www.windowsforms.net/TrackViews.aspx?ID=186&Type=Samples&Redir=http%3a%2f
%2fwindowsforms.net%2fdownloads%2fgdn%2fXhtml2Rtf.zip

[quoted text clipped - 7 lines]
> > Thanks,
> > Serge.
- 23 Jun 2004 23:19 GMT
Go to the Form Designer and right-click on the top of the Windows Forms
section of the tools list and click on Add/Remove Items...

Go to the COM Components page and check the "Microsoft Web Browser".

Then go to the bottom of the list of items under Windows Forms and drag the
web browser onto your form.

It's a COM component, but it's wrapper up very nicely. Take a look at the
documentation for IWebBrowser2 to find out how to manipulate it, but for the
most part, you treat it like a .NET component.

Do a google search on axWebBrowser and you'll find some sample code. I know
there are a few on Code Project.

Pete

> I am looking for a way to view HTML in Winform application. Does anyone know if there is something like a browser control that I could use to render
the HTML?

> Thanks,
> Serge.
Sahil Malik - 23 Jun 2004 23:19 GMT
Yeh that'll work, but you get a real heavy duty axWebBrowser control ..
kinda like killing a fly with a hammer .. but if you must use that .. here
is sample code to render a "text" to a webbrowser control -

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using mshtml;

namespace WindowsApplication2
{
       public class Form1 : System.Windows.Forms.Form
       {
               private AxSHDocVw.AxWebBrowser browser;
               private System.ComponentModel.Container components = null;

               public Form1()
               {
                       InitializeComponent();
                       string url = "about:blank";
                       object o = System.Reflection.Missing.Value;
                       browser.Navigate ( url,ref o,ref o,ref o,ref o);

AxSHDocVw.DWebBrowserEvents2_StatusTextChangeEventHandler handler =
                         new
AxSHDocVw.DWebBrowserEvents2_StatusTextChangeEventHandler
                         (this.browser_StatusTextChange);
                       browser.StatusTextChange += handler;
               }

               private void browser_StatusTextChange
                       (object sender,
AxSHDocVw.DWebBrowserEvents2_StatusTextChangeEvent e)
               {

                       mshtml.HTMLDocument doc =
(mshtml.HTMLDocument)this.browser.Document;
                       doc.body.innerHTML = "<H1>foo</H1>";
               }

               protected override void Dispose( bool disposing )
               {
                       if( disposing )
                       {
                               if (components != null)
                               {
                                       components.Dispose();
                               }
                       }
                       base.Dispose( disposing );
               }

               #region Windows Form Designer generated code

               private void InitializeComponent()
               {
                       System.Resources.ResourceManager resources = new

System.Resources.ResourceManager(typeof(Form1));
                       this.browser = new AxSHDocVw.AxWebBrowser();

((System.ComponentModel.ISupportInitialize)(this.browser)).BeginInit();
                       this.SuspendLayout();
                       //
                       // browser
                       //
                       this.browser.Enabled = true;
                       this.browser.Location = new System.Drawing.Point(16,
16);
                       this.browser.OcxState =

((System.Windows.Forms.AxHost.State)(resources.GetObject("browser.OcxState")
));
                       this.browser.Size = new System.Drawing.Size(344,
224);
                       this.browser.TabIndex = 0;
                       //
                       // Form1
                       //
                       this.AutoScaleBaseSize = new System.Drawing.Size(5,
13);
                       this.ClientSize = new System.Drawing.Size(392, 302);
                       this.Controls.AddRange(new
System.Windows.Forms.Control[] {
this.browser});
                       this.Name = "Form1";
                       this.Text = "Form1";

((System.ComponentModel.ISupportInitialize)(this.browser)).EndInit();
                       this.ResumeLayout(false);

               }
               #endregion

               [STAThread]
               static void Main()
               {
                       Application.Run(new Form1());
               }

       }
}

Signature

- Sahil Malik
Independent Consultant
You can reach me thru my blog - http://dotnetjunkies.com/WebLog/sahilmalik/

> Go to the Form Designer and right-click on the top of the Windows Forms
> section of the tools list and click on Add/Remove Items...
[quoted text clipped - 19 lines]
> > Thanks,
> > Serge.
Herfried K. Wagner [MVP] - 24 Jun 2004 00:03 GMT
* "=?Utf-8?B?U2VyZ2U=?=" <Serge@discussions.microsoft.com> scripsit:
> I am looking for a way to view HTML in Winform application. Does
> anyone know if there is something like a browser control that I could
> use to render the HTML?

311303 WebOCHostVB.exe Hosts the WebBrowser Control in Visual Basic .NET
<URL:http://support.microsoft.com/?id=311303>

Signature

Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.