gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 21:57:36 26 4
gpt4 key购买 nike

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

我是 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com