这就是我所拥有的:
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/