如何从列表框中的webbrowser获取URI? 此代码添加20 URI而不是1:
private void webBrowser1_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
radListControl1.Items.Add(webBrowser1.Url.AbsoluteUri.ToString());
}
或
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
radListControl1.Items.Add(webBrowser1.Url.AbsoluteUri.ToString());
}
答案 0 :(得分:1)
if (!radListControl1.Items.Contains(webBrowser1.Url.ToString()))
radListControl1.Items.Add(webBrowser1.Url.ToString());
因为在单页加载中多次触发此事件...
答案 1 :(得分:1)
您需要检查事件提供的URI与浏览器中的URI:
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (e.Url.Equals(webBrowser1.Url))
// this is the real one
}
编辑:实际上,it has already been answered。