c# - 如何将 URL 地址连接到图像

标签 c#

我又回来了,需要你的帮助!

我是 C# 的新手,但我想学习它。

我的新问题是:

private void Form2_Load(object sender, EventArgs e)
    {
        pictureBox1.ImageLocation = "http://www.jmorganmarketing.com/wp-content/uploads/2010/11/image4.jpg";
    }

上面的代码是从 URL 地址加载图像。现在我想让这张图片可以点击,当它被点击时,默认浏览器应该打开并显示 stackoverflow.com (例如) 我想 mouseclick 事件应该有一些东西,但是我怎样才能在默认浏览器中打开 URL? 有没有简单的方法可以做到这一点?

非常感谢任何回复!!!!

最佳答案

Process.Start("http://www.stackoverflow.com");

会做的。 From the documenation

Starting a process by specifying its file name is similar to typing the information in the Run dialog box of the Windows Start menu. Therefore, the file name does not need to represent an executable file. It can be of any file type for which the extension has been associated with an application installed on the system. For example the file name can have a .txt extension if you have associated text files with an editor, such as Notepad, or it can have a .doc if you have associated.doc files with a word processing tool, such as Microsoft Word. Similarly, in the same way that the Run dialog box can accept an executable file name with or without the .exe extension, the .exe extension is optional in the fileName parameter. For example, you can set the fileName parameter to either "Notepad.exe" or "Notepad".

因此,当您使用 URI 启动进程时,将启动默认浏览器。

关于c# - 如何将 URL 地址连接到图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11594784/

相关文章:

c# - 将树结构转换/转换为不同类型

c# - 如何启动浏览器然后将其定向到页面?

c# - "Ø"作为 C# 中的输入

c# - 让客户端提取数据

c# - Mvc 4 添加带有脚手架的 Controller 给出错误 - "Unable to retrieve metadata..."

c# - 如何在 SQL Server 数据库中存储 C# 属性并调用命令?

c# - 使用 Moq 测试计时器

c# - 使用C#动态生成CSS文件

c# - 使用 ninject.extensions.conventions 多次绑定(bind)服务

c# - 有什么方法可以在配置而不是代码中设置 Web 服务的命名空间?