为什么我不能使用 C# winforms 在新 window 中打开网页?

Why can't I open a webpage in a new window using C# winforms?

我对 C# winforms 很感兴趣。我决定在使用默认浏览器单击 link 标签后,让它打开浏览器 window。我在互联网上搜索并找到以下代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GUI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                VisitLink();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to open link that was clicked.");
            }
        }

        private void VisitLink()
        {
            // Change the color of the link text by setting LinkVisited
            // to true.
            linkLabel1.LinkVisited = true;
            //Call the Process.Start method to open the default browser
            //with a URL:
            System.Diagnostics.Process.Start("http://www.microsoft.com");
        }
    }
}

当我在我的代码中尝试时,我点击了 link 但没有任何显示。甚至没有弹出异常,这让我很困惑。谁能帮我?谢谢!

点击后 link 是否正确标记为已访问?如果没有,事件可能甚至没有被解雇。检查是否正确添加了点击事件的回调