private void ShowNewForm(object sender, EventArgs e) { TextForm childForm = new TextForm(); childForm.MdiParent = this; childForm.Text = "新建文档" + childFormNumber++; childForm.Show(); //tfArr.Add(childForm); }
private void OpenFile(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "文本文件(*.txt)|*.txt|Rtf文档(*.rtf)|*.rtf"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { string str; string FileName = openFileDialog.FileName; StreamReader sr = new StreamReader(FileName, Encoding.Default); TextForm tf = new TextForm(); tf.MdiParent = this; tf.Text = FileName; tf.Show(); while ((str = sr.ReadLine()) != null) { tf.getRichTextBox().Text += str + '\n'; } } }