Form1.cs
上传用户:len11608
上传日期:2022-06-26
资源大小:21k
文件大小:2k
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace abc
- {
- public partial class MdiFather : Form
- {
- private int numberoftext = 2;
- public MdiFather()
- {
- InitializeComponent();
- MdiChild child = new MdiChild(this,"新建文档");
- child.Show();
- }
- private void MenuNew_Click(object sender, EventArgs e)
- {
- string caption;
- caption = "新建文档" + numberoftext++;
- MdiChild child = new MdiChild(this, caption);
- child.Show();
- }
- private void MenuAbout_Click(object sender, EventArgs e)
- {
- About newf = new About();
- newf.Text = "关于对话框";
- newf.ShowDialog();
- }
- private void MenuExit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void MenuOpen_Click(object sender, EventArgs e)
- {
- OpenFileDialog opdlg = new OpenFileDialog();
- DialogResult dlgResult;
- dlgResult = opdlg.ShowDialog();
- try
- {
- if (dlgResult == DialogResult.OK)
- {
- string name = opdlg.FileName;
- MdiChild child = new MdiChild(this, name);
- child.rtbText.LoadFile(name, RichTextBoxStreamType.RichText);
- child.Show();
- child.Textchanged = false;
- }
- }
- catch (Exception)
- {
- MessageBox.Show("错误", "格式错误", MessageBoxButtons.OK);
- }
- }
- }
- }