如何在Web浏览器中禁用html控件

时间:2014-12-12 03:35:40

标签: c# html vb.net winforms webbrowser-control

为什么我无法更改浏览器控件中HTML元素的可见性/已启用属性。我使用的代码如下:

  webBrowser.Document.GetElementById("myCombo").SetAttribute("Visible", "False")
  webBrowser.Document.GetElementById("myCombo").SetAttribute("Enabled", "False")

在这种情况下我做错了什么?

2 个答案:

答案 0 :(得分:0)

要隐藏元素,请使用此选项:

webBrowser.Document.GetElementById("myCombo").Enabled = False

要显示元素,请使用:

webBrowser.Document.GetElementById("myCombo").Enabled = True

答案 1 :(得分:0)

这样做:

 webBrowser.Document.GetElementById("myCombo").Enabled = False '<--- for disable the control
 webBrowser.Document.GetElementById("myCombo").Enabled = True'<--- for enable the control