Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 更改web浏览器控件滚动条的颜色_C#_Winforms - Fatal编程技术网

C# 更改web浏览器控件滚动条的颜色

C# 更改web浏览器控件滚动条的颜色,c#,winforms,C#,Winforms,我正在windows应用程序中使用web浏览器控件。我想改变滚动条的外观和感觉。我找到了下面给出的代码项目链接。 这似乎更麻烦。因此,除了这个,还有其他定制滚动条的方法。我想设计没有上下箭头的滚动条。只是滚动条。我无法使用此代码执行此操作。或者我可以更改默认滚动条的外观,如颜色宽度等。您可以使用设置样式表: IHTMLDocument2 _htmlDocument = webBrowser.Document.DomDocument as IHTMLDocument2; int length =

我正在windows应用程序中使用web浏览器控件。我想改变滚动条的外观和感觉。我找到了下面给出的代码项目链接。 这似乎更麻烦。因此,除了这个,还有其他定制滚动条的方法。我想设计没有上下箭头的滚动条。只是滚动条。我无法使用此代码执行此操作。或者我可以更改默认滚动条的外观,如颜色宽度等。

您可以使用设置样式表:

IHTMLDocument2 _htmlDocument = webBrowser.Document.DomDocument as IHTMLDocument2;
int length = _htmlDocument.styleSheets.length;
IHTMLStyleSheet styleSheet = _htmlDocument.createStyleSheet(@"", length + 1);
styleSheet.addRule("BODY", "scrollbar-face-color: #FF0000;");
styleSheet.addRule("BODY", "scrollbar-highlight-color: #FF00FF;");
styleSheet.addRule...
或者您可以直接在
HTML
code中设置
CSS

CSS:

<STYLE type="text/css">
<!--
BODY
{
scrollbar-face-color: #FF0000;
scrollbar-highlight-color: #FF00FF;
scrollbar-3dlight-color: #00FF00;
scrollbar-darkshadow-color: #00FFFF;
scrollbar-shadow-color: #0000FF;
scrollbar-arrow-color: #FF00FF;
scrollbar-track-color: #FFFF00;
}
-->
</STYLE>

注意:只有在运行IE 5.5时才能看到彩色滚动条。

很抱歉,问题中缺少链接:您不能在加载的页面中插入一些CSS代码吗?事实上,我相信滚动条不属于控件本身,而是属于控件内的网页。@Steve B-实际上我正在使用windows窗体,在该窗体中我添加了web浏览器控件。我们可以在windows窗体中使用CSS吗?我不知道。如果是,请告诉我怎么做。谢谢您必须了解的是,滚动条不是由WebBrowserControl管理的,而是由网页本身管理的。实际上,这是Internet Explorer中的滚动条,而不是控件本身。说明我的意思。它显示了如何自定义页面的滚动条,而不是控件。@Steve:谢谢您的解释。现在我想减小滚动条的宽度。那有什么财产吗?如果是,请告诉我怎么做。谢谢
webBrowser.DocumentText = "<html><head><STYLE type=\"text/css\"><!--BODY{scrollbar-face-color: #FF0000;scrollbar-highlight-color: #FF00FF;scrollbar-3dlight-color: #00FF00;scrollbar-darkshadow-color: #00FFFF;scrollbar-shadow-color: #0000FF;scrollbar-arrow-color: #FF00FF;scrollbar-track-color: #FFFF00;}--></STYLE></head><body>aaaa</body></html>";