public FormEditor(string[] files = null) { InitializeComponent(); tabControl.ControlAdded += TabControl_ControlAddedOrRemoved; tabControl.ControlRemoved += TabControl_ControlAddedOrRemoved; tabControl.SelectedIndexChanged += (sender, arg) => f5Title(); quitToolStripMenuItem.Click += (sender, arg) => Close(); f5Buttons(); if (files == null) { tabControl.Controls.Add(new Editor(this)); } else { foreach (var file in files) { var editor = new Editor(this); if (editor.openFile(file)) tabControl.Controls.Add(editor); } } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog(); ofd.Filter = "文本文档|*.txt|所有文件|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { var editor = new Editor(this); editor.openFile(ofd.FileName); tabControl.Controls.Add(editor); tabControl.SelectedTab = editor; } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { var tp = new Editor(this); tabControl.Controls.Add(tp); tabControl.SelectedTab = tp; }