webBrowser导航到listBox选中的值 [英] webBrowser navigation to listBox selected value

查看:47
本文介绍了webBrowser导航到listBox选中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< hello

我有一个Web浏览器和一个显示来自sql server数据库的url的listBox,我如何告诉webBrowser导航到listBox选择的url?我尝试了这个代码,但它留在第一个网址!请帮助我!



<hello
i have a web browser and a listBox showing urls from an sql server database, how can i tell to the webBrowser to navigate to listBox selected url? i tried this code but it stay on the first url! help me please!

private void listBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            string url = listBox1.SelectedValue.ToString();
            webBrowser1.Navigate(url);
 
        }





谢谢



thanks

推荐答案

改变这一行

string url = listBox1.Text;



to



string url = listBox1.SelectedText;



试一试。
change this line
string url = listBox1.Text;

to

string url = listBox1.SelectedText;

try it.


这篇关于webBrowser导航到listBox选中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆