c#莫名其妙报错,?

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 Add_Controls_Manually
{
    public class Form1:Form
    {
        public Form1(){
            InitializeComponent();
            and();
        }
        void and(){
            Button btn = new Button();
            btn.Text = "hi";
            btn.Width = 100;
            btn.Height = 50;
            btn.Click += btn_click;
            this.Controls.Add(btn);
        }
        void btn_click(object sender,EventArgs e){
            MessageBox.Show("hi");
        }
    }
    static class m{
        [STAThread]
        static void Main(){
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}


运行报错:上下文中没有initializecomponent()

我把initializecomponent()删了却好了

InitializeComponent 需要有designer.cs 文件支持,如果你把这个文件删除了,那么界面部分你需要自己手写了,InitializeComponent就是调用界面初始化及事件的默认方法。