DataGridView Web链接 [英] DataGridView web links

查看:110
本文介绍了DataGridView Web链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在同一Windows窗体上有一个DataGridView和一个Web浏览器,我可以获取我的Web链接列表以正确填充数据网格,但是单击链接时我无法将其加载到Web浏览器中.我已经将默认的Google设置为浏览器,并且运行正常.当我单击数据网格视图中的链接时,该页面将变为空白.对此完全陌生,因此任何代码示例都将是很棒的.感谢您的帮助,Brian

Hello, I have a DataGridView and a web browser on the same windows form and I can get my list of web links to populate the data grid properly but I cannot get the links to load into the web browser when I click them. I have set a default Google into the browser and that works fine. When I click the links in the data grid view the page goes blank. Totally new to this, so any code examples would be great. Thanks for any help, Brian

推荐答案

HTML 标签是解决您问题的方法.

Html tag is the solution for your problem.

<a href="http://www.google.com" target="_blank">Visit Google</a>



上面的HTML代码在网络浏览器的新窗口或新标签页中创建了Google页面.有关更多信息,请访问: http://www.w3schools.com/tags/tag_a.asp [ ^ ]



The above HTML code creates google page in a new window or tab of the web browser. More info at: http://www.w3schools.com/tags/tag_a.asp[^]


您是说您使用System.Windows.Forms.WebBrowser类?单击时,您需要获取单元格数据(作为字符串)并将其用作参数System.Windows.Forms.WebBrowser.Navigate,尤其是Navigate(string urlString)Navigate(Uri url).第二种形式更好,因为Uri构造函数将引发异常,因此您将知道在字符串参数中提供了无效的URI.

请参阅 http://msdn.microsoft.com/en-us/library/system .windows.forms.webbrowser.aspx [ ^ ].

—SA
Do you mean you use System.Windows.Forms.WebBrowser class? On click, you need to get a cell data (as a string) and use it as a parameter System.Windows.Forms.WebBrowser.Navigate, in particular, Navigate(string urlString) or Navigate(Uri url). The second form is better because Uri constructor will throw exception so you will know of you supply invalid URI in the string parameter.

See http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx[^].

—SA


您好,感谢您提供的信息.我最终使用了这个
Hello, thanks for the info. I ended up using this
WebBrowser1.Navigate(DataGridView1.CurrentCell.Value.ToString())

,我不知道这是否是最好的方法,但是现在可以使用了.当我在整行中的任意位置单击时,是否可以使用方法而不是使用CurrentCell来告诉程序单击第6列中的链接?我已经设置了datagridview来突出显示整个行,但是现在我必须单击链接本身才能使其工作.再次感谢.

I don''t know if it''s the best way but it works for now. Is there a way instead of using CurrentCell to tell the program to the click the link located in column 6 when I click anywhere in the whole row? I have set up the datagridview to highlight the whole row but right now I have to click on the link itself for it to work. Thanks again.


这篇关于DataGridView Web链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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