C#窗体立即关闭

本文关键字:窗体 | 更新日期: 2023-09-27 18:03:48

应用程序一启动,我的窗体窗口就突然开始关闭。输出窗口中没有任何内容提示可能是什么原因导致的,也没有向我抛出任何错误。有人有什么想法吗?

我已经为form的班级提供了。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ProjectBoardManagement {
  public partial class CreateBoard : Form {
    Functions funcs = new Functions();
    public CreateBoard() {
      InitializeComponent();
    }
    private void CreateBoardButton_Click(object sender, EventArgs e) {
      String BoardName = BoardNameText.Text;
      String Pages = "";
      String Labels = "";
      foreach (ListViewItem i in PageNameList.Items) {
        Pages = (Pages + i.Name.ToString() + ",");
      }
      foreach (ListViewItem i in LabelNameList.Items) {
        Labels = (Labels + i.Name.ToString() + ",");
      }
      String BoardFile = ("board_" + BoardName + ".txt");
      funcs.SaveSetting(BoardFile, "name", BoardName);
      funcs.SaveSetting(BoardFile, "pages", Pages);
      funcs.SaveSetting(BoardFile, "labels", Labels);
      FormManagement.CreateBoard.Hide();
      FormManagement.BoardList.LoadBoardList();
    }
    private void PageNameButtonAdd_Click(object sender, EventArgs e) {
      String pagename = PageNameText.Text;
      if (pagename != "") {
        PageNameList.Items.Add(pagename);
      }
      PageNameText.Text = "";
    }
    private void LabelNameButtonAdd_Click(object sender, EventArgs e) {
      String labelname = LabelNameText.Text;
      if (labelname != "") {
        LabelNameList.Items.Add(labelname);
      }
      LabelNameText.Text = "";
    }
  }
}

C#窗体立即关闭

显而易见的第一件事是在调试模式下运行它,并停止对所有异常的执行。这应该会给你足够的信息,告诉你如何从那里开始。

否则Functions funcs = new Functions();看起来可疑。