按鈕點擊打開網頁,我想呈現網頁(谷歌),當我在表格(WinForm的),點擊按鈕....形式
我曾嘗試下面的代碼,但它不爲我工作.....
public partial class Form1 : Form {
bool mHooked;
public Form1() {
InitializeComponent();
webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;
webBrowser1.Navigate("http://www.google.com");
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
if (mHooked) return;
// Get the form
HtmlDocument doc = webBrowser1.Document;
HtmlElement form = doc.Forms["f"];
// Get the "I'm feeling lucky" button
HtmlElement lucky = form.All["btnI"];
lucky.Click += lucky_Click;
mHooked = true;
}
void lucky_Click(object sender, EventArgs e) {
this.Close();
}
}
我使用C#做的WinForms應用
將在此任何一個請幫助.....
許多在此先感謝...
105:您還沒有提供任何鏈接按鈕點擊 – 62071072SP
爲什麼你不在點擊事件中設置網址? – V4Vendetta
@ V4Vendetta我不知道如何纔剛剛嘗試過一個...... –