0

你能解释为什么我会收到这个错误吗?

    private void startButton_Click(object sender, EventArgs e)
    {
        HtmlElement mainNav = webBrowser1.Document.GetElementByID("home");
            mainNav.InvokeMember("click");
    }

错误 1

'System.Windows.Forms.HtmlDocument' does not contain a definition for 'GetElementByID' and no extension method 'GetElementByID' accepting a first argument of type 'System.Windows.Forms.HtmlDocument' could be found (are you missing a using directive or an assembly reference?)
4

1 回答 1

2

因为它是GetElementById, 带有小写的 'd'。

文档位于:http: //msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.getelementbyid.aspx


旁注:谷歌搜索system.windows.forms.htmldocument让我找到了要检查的文档,Intellisense 也应该能够告诉你正确的拼写。不过,我确实意识到有时需要额外的一双眼睛。

于 2013-01-02T18:13:15.457 回答