0

I want to run my HTML document inside the form in Windows Forms App project.

The document contains link to CSS file:

<link rel="stylesheet" href="CssSample.css">

It should be open inside the form, not as file in Chrome.

Thank you!

  • 1
    Does this answer your question? [include static JS and CSS WebBrowser control](https://stackoverflow.com/questions/27661986/include-static-js-and-css-webbrowser-control) – oleksa Aug 02 '21 at 12:37
  • I am going to try it now. Thank you! –  Aug 02 '21 at 13:34
  • No, he described another issue. He knew how to do it and received the error. And I don't know how to implement it. –  Aug 02 '21 at 13:42
  • 1
    you may use the same approach as was described: put the [WebBrowser control](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/controls/webbrowser-control-overview?view=netframeworkdesktop-4.8) on a form and use file css links like `file:///C:\some\path.css` in a html source to get css applied. – oleksa Aug 03 '21 at 07:23

1 Answers1

0

The support for style sheets is enabled in HTMLUI. This lets the user to define styles for HTML elements and decide the appearance of the HTML elements in the application. HTMLUI supports three types of style sheets.

  • External Style sheets
  • Internal Style sheets
  • Inline Style sheets

External style sheets are linked to the file through the Link tag. While the internal style sheets are applied with the help of the Style tag inside the head section, inline style sheets are applied as the values of the style attributes of the specific HTML element.

htmluiControl.LoadHTML(@"C:\MyProjects\StyleSheets\external.html");

htmluiControl.LoadCSS(@"C:\MyProjects\StyleSheets\NewStyleSheet.css");

for HTM-viewer/style-sheets - https://help.syncfusion.com/windowsforms/html-viewer/style-sheets-css

Also see this - https://help.syncfusion.com/windowsforms/html-viewer/loading-html

  • I can't add htmluiControl, the reference is not found. –  Aug 02 '21 at 10:01
  • This section lists needed assembly or NuGet references to use any control in the application. You can refer to the deployment section to know assembly installation location and NuGet packages section to know how to add NuGet reference. Please visit - https://help.syncfusion.com/windowsforms/control-dependencies#htmluicontrol – Muhammad Sunny Aug 02 '21 at 10:24
  • Actually, there is no NuGet package 'Syncfusion.HTMLUI.Windows' –  Aug 02 '21 at 10:49
  • https://help.syncfusion.com/windowsforms/visual-studio-integration/nuget-packages – Muhammad Sunny Aug 02 '21 at 11:07