ShowDialog无法打开窗体Visual Studio

时间:2018-11-21 08:52:05

标签: c#

当我尝试在Visual Studio中打开表单时,它不起作用。我已经尝试了许多解决方案,但仍然无法正常工作,问题可能出在不同的代码中吗?这是我正在使用的代码:

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();
        }
    }
}

2 个答案:

答案 0 :(得分:0)

你是说吗?

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

}

答案 1 :(得分:0)

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

 MessageBox.Show(this, "Title", "Message");

如果您想要自定义对话框,也可以使用该对话框

_FormDialog dialog = new _FormDialog(this);
dialog.ShowDialog();

_FormDialog是您创建的寡妇表单。