这是我的:
public void initiate(WebBrowser browser)
{
browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(refDocumentCompleted);
// navigate browser to the referal Uri
browser.Navigate(refreral);
browser.DocumentCompleted -= refDocumentCompleted;
//remove here so that it doesn't do this everytime a document is completed, i want it just in this method
}
private void refDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// want to call navigate method on browser here. but Its out of scope.
}
我希望它做的是,导航到 referral
,然后在加载后导航到另一个页面,该页面存储为类中的全局字符串。
我确定我在这里的麻烦是由于对事件如何运作的理解不足,我已经尝试阅读它,但似乎无法理解它但我认为我不需要创建我自己的处理程序。
最佳答案
您已经有了 webbrowser 对象。你只需要施放它:
((WebBrowser)sender).Navigate(...);
等等
关于c# - 如何在事件处理程序内调用 WebBrowser 上的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12326509/