For adding an css file to browser in Winform/Wpf ,
First-> Add "microsoft HTML object library (MSHTML).dll" to
"reference" of your project.
Second-> Add "using mshtml" & "using System.IO" namespaces to code file.
Third-> Add/Create a CSS file that want to add in webbrowser to customize
HTML code/visual.
Final-> Add/Write following codes under windows_load event to enable
css to webbrowser.
First-> Add "microsoft HTML object library (MSHTML).dll" to
"reference" of your project.
Second-> Add "using mshtml" & "using System.IO" namespaces to code file.
Third-> Add/Create a CSS file that want to add in webbrowser to customize
HTML code/visual.
Final-> Add/Write following codes under windows_load event to enable
css to webbrowser.
Code Follows :-
mshtml.HTMLDocument CurrentDocument = (mshtml.HTMLDocument)WebBrowser1.Document.DomDocument; mshtml.IHTMLStyleSheet styleSheet = CurrentDocument.createStyleSheet("", 0); StreamReader streamReader = new StreamReader(@"..\browser.css"); //browser.css is Stylesheet file string text = streamReader.ReadToEnd(); streamReader.Close(); styleSheet.cssText = text;
3 comments: (+add yours?)
unknown object DomDocument
Yes worked for me..Thank you :)
Respect and that i have a tremendous provide: Does Renovation Increase House Value renovate my home
Post a Comment