Reputation: 37
I'm just creating a simple calculator in C# (Windows Form).
I've created a "User Help" which is an HTML file, what I want is to display that HTML file if the user clicks on the "Help" button in the WinForm.
How to open the HTML file on button click in WinForm?
I don't plan to provide this PDF file on hard disk of user, which means that I have to embed this HTML into the calculator (WinForm) and have to display it on the button click.
Upvotes: 3
Views: 17833
Reputation: 122
If you to using Visual Studio, you can do.
1)Add control WebBrowser
in the winform
2)Add file html on resource in the project, click right button to do
3)Then write
string html = Properties.Resources.Details;
webBrowser1.DocumentText = html;
I hope useful this is
Upvotes: 1
Reputation: 7355
You could use the WebBrowser
control.
Check: How to: Add Web Browser Capabilities to a Windows Forms Application
Upvotes: 1
Reputation: 144
The easiest way to put your Html pages on Winforms is to load it on webBrowser Control by this lines:
var uri = new Uri(filepath);
webBrowser1.Navigate(uri);
or load your html texts to webbrowsers html by this
FileStream source = new FileStream(filepath, FileMode.Open, FileAccess.Read);
webBrowser1.DocumentStream = source;
or
string html = File.ReadAllText(filepath);
webBrowser1.DocumentText = html;
Upvotes: 3