C# ShowDialog未打开Visual Studio窗体

C# ShowDialog未打开Visual Studio窗体,c#,C#,当我尝试在VisualStudio上打开表单时,它不起作用。我已经尝试了很多解决方案,但仍然不起作用,问题是否存在于不同的代码中?以下是我正在使用的代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Thr

当我尝试在VisualStudio上打开表单时,它不起作用。我已经尝试了很多解决方案,但仍然不起作用,问题是否存在于不同的代码中?以下是我正在使用的代码:

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 VBR_Application
{
    public partial class addNewGT : Form
    {
        public addNewGT()
        {
            InitializeComponent();
        }

        private void addOnline_Click(object sender, EventArgs e)
        {
            var newForm = new AddOnline();
            newForm.Show();
        }
    }
}
你是说

private void addOnline_Click(object sender, EventArgs e)
{
    var newForm = new Form();
    newForm.Show();

}

如果要显示内置对话框,可以使用此对话框

 MessageBox.Show(this, "Title", "Message");
_FormDialog dialog = new _FormDialog(this);
dialog.ShowDialog();
如果需要自定义对话框,也可以使用此对话框

 MessageBox.Show(this, "Title", "Message");
_FormDialog dialog = new _FormDialog(this);
dialog.ShowDialog();

_FormDialog是您创建的widows表单。

您没有调用ShowDialog。请在var newForm=new AddOnline;上设置断点;。运行代码。点击按钮。断点被击中了吗?几乎肯定不会。Form是所有表单的基类,我知道它不是一个特定的Form,但他的意思是他不能打开一个新表单吗?或newForm.ShowDialog;