【问题标题】:How to connect WInform to Webform in Visual Studio如何在 Visual Studio 中将 WInform 连接到 Webform
【发布时间】:2019-11-24 15:03:01
【问题描述】:

当我点击“winform”中的按钮时,会显示“webform”

喜欢:

private void Button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
            f2.ShowDialog();

        }

或:

【问题讨论】:

  • 在 VS2019 .net 4 中
  • 这确实是一个棘手的问题,因为 WinForms 应用程序通常不绑定到 WebForms 应用程序。您可以在该按钮单击事件中打开 Web 浏览器以打开您喜欢的网页,或托管 WebBrowser 控件以加载该页面。同样,只有当您更具体地了解您想要实现的目标时,才会有答案。

标签: c# visual-studio winforms webforms connect


【解决方案1】:

实际上,您的代码对于打开另一个带有对话框的表单是绝对正确的,但是如果您想打开网站的页面,请使用此代码

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 frm2 = new Form2();
            frm2.Show();
            linkLabel1.LinkVisited = true;
        }
        private void VisitLink()
        {
            linkLabel1.LinkVisited = true;
            System.Diagnostics.Process.Start("http://www.microsoft.com");
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            VisitLink();
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-01
    • 2021-10-18
    • 1970-01-01
    • 1970-01-01
    • 2020-10-31
    • 2013-12-07
    • 1970-01-01
    相关资源
    最近更新 更多