[英]Select item in listbox to go to that url?
when I click on a item in my listbox I need to go to that URL. 当我单击列表框中的项目时,我需要转到该URL。 But I am getting the error
Cannot conver System.Uri to string
但是我收到错误消息
Cannot conver System.Uri to string
Here is my code: 这是我的代码:
private void lbFavo_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (lbFavo.SelectedItem != null)
{
string link = lbFavo.SelectedText;
webBrowser.Navigate(lbFavo.SelectedItem);
}
}
You have to give full url of the site with http or https, for example 例如,您必须使用http或https来提供网站的完整URL。
//Fine
webBrowser1.Navigate("https://www.google.lk");
//Error //错误
webBrowser1.Navigate("www.google.lk");
So make sure you pass the qualified url to the Navigate() method. 因此,请确保将合格的URL传递给Navigate()方法。 Also you can't directly use SelectedItems property use the following code,
另外,您不能直接使用SelectedItems属性使用以下代码,
webBrowser1.Navigate(listBox1.SelectedItem.ToString());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.