C# Can';t以编程方式隐藏webBrowser控件中的侧栏

C# Can';t以编程方式隐藏webBrowser控件中的侧栏,c#,html,winforms,webbrowser-control,C#,Html,Winforms,Webbrowser Control,在winforms中的webBrowser控件中加载后,在DocumentCompleted事件中,我试图用id=pullout隐藏侧栏 var divs = webBrowser.Document?.GetElementsByTagName("div"); if (divs == null) return; foreach (var pulloutDiv in divs.Cast<HtmlElement>().Where(h => h.Id == "pullout")) {

在winforms中的webBrowser控件中加载后,在
DocumentCompleted
事件中,我试图用
id=pullout
隐藏侧栏

var divs = webBrowser.Document?.GetElementsByTagName("div");
if (divs == null) return;

foreach (var pulloutDiv in divs.Cast<HtmlElement>().Where(h => h.Id == "pullout"))
{
    pulloutDiv.SetAttribute("class", "hidden");
}
var divs=webBrowser.Document?.GetElementsByTagName(“div”);
if(divs==null)返回;
foreach(divs.Cast()中的var pulloutDiv,其中(h=>h.Id==“pullout”))
{
pulloutDiv.SetAttribute(“类”、“隐藏”);
}

但这没什么用。我想知道我做错了什么。是否因为页面已经加载,对html所做的任何更改都会被忽略

将类更改为类名:

foreach (var pulloutDiv in divs.Cast<HtmlElement>().Where(h => h.Id == "pullout"))
{
    pulloutDiv.SetAttribute("className", "hidden");
}
foreach(divs.Cast()中的var pulloutDiv,其中(h=>h.Id==“pullout”))
{
pulloutDiv.SetAttribute(“className”、“hidden”);
}

太棒了,但是为什么
className
而不是
class
?如果要更改
边距
属性值,我会使用什么?微软有它自己的秘密!!;)我也很难发现它;)好的,实际上提到了
className