无法以编程方式隐藏 webBrowser 控件中的边栏

Can't hide a sidebar in a webBrowser control programatically

在 winforms 的 webBrowser 控件中加载 page 后,在 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");
}

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

将 class 更改为 class姓名:

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