0

我在使用 Enter 键导航浏览器时遇到问题。

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    switch (keyData)
    {
        case Keys.Enter:
            go_Click.PerformClick();
            return true;
    }
    return false;
}

我的go_Click

private void go_Click(object sender, EventArgs e)
{
    //declares URL as string variable
    string url = textbox.Text;

    //if statment to determine if URL is correct
    if (url == "")
    {
        MessageBox.Show("Please enter a valid URL!");
    }

    if (url.Substring(0, 3) == "www")
    {
        url = "http://" + url;
        webBrowser1.Navigate(url);
    }
}

它返回一个错误,错误状态是一个在给定上下文中无效的方法。

4

1 回答 1

1

更改这行代码go_Click.PerformClick();

go_Click(null, null);

于 2013-08-30T10:05:24.967 回答