• 大小: 92.99 KB
    文件类型: .rar
    金币: 1
    下载: 1 次
    发布日期: 2024-10-04
  • 语言: C#
  • 标签: C#  记事本  

资源简介

实现多窗口模式记事本,及实现类似于word的查找/替换功能,功能完善.

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ex4_1
{
    public partial class childForm : Form
    {
      
        public childForm(Form1 parentint title)
        {
            InitializeComponent();
            this.MdiParent = parent;
          //  title++;
            this.Text = “无标题-记事本“ + title;
        }

        public void childForm_FormClosing(object sender FormClosingEventArgs e)
        {
          

            if (richTextBox1.Modified)
            {
               
                
                  DialogResult dr = MessageBox.Show(“文件“ + this.Text+ “的文字已经改变。\n想保存文件吗?“ “记事本“ MessageBoxButtons.YesNoCancel MessageBoxIcon.Asterisk);
                    switch (dr)
                    {
                        case DialogResult.Yes:
                            saveMenuItem_Click(sender e);
                            if (richTextBox1.Modified)
                            {
                                e.Cancel = true;
                            }
                            break;
                        //no操作继续执行后续操作
                        case DialogResult.No:
                            break;
                        //取消操作不执行后续动作
                        case DialogResult.Cancel:
                            e.Cancel = true;
                            break;
                    }
                }
            
        }
        private void saveMenuItem_Click(object sender EventArgs e)
        {
            // string mFileName = this.ActiveMdiChild.Text;
            string fileName = this.Text;
            string richText =richTextBox1.Text;
            string pathName =pathLabel.Text;
           
            Console.WriteLine(fileName);
            try
            {
                if (fileName.StartsWith(“无标题-记事本“))
                {
                    saveAsStripMenuItem_Click(sender e);
                }
                else
                {
                richTextBox1.Modified = false;
                   
                    //filename应为当前文件filename
                    StreamWriter sWriter = new StreamWriter(pathName false);
                    sWriter.Write(richText);
                    sWriter.Close();
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message.ToString());
            }


        }
        private void saveAsStripMenuItem_Click(object sender EventArgs e)
        {
            Form1 mdiParent = (Form1)this.MdiParent;
            int n = mdiParent.getNumber();

            n++;
            saveAsFileDialog.FileName = “新pot文档“ + n;
            try
            {
                if (saveAsFileDialog.ShowDialog() == DialogResult.OK)
                {
                    richTextBox1.Modified = f

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        904  2008-10-08 23:14  复件 ex4-1\ex4-1.sln

    ..A..H.     22016  2008-11-01 15:25  复件 ex4-1\ex4-1.suo

     文件       8683  2008-10-26 20:30  复件 ex4-1\ex4-1\replace.cs

     文件      11426  2008-10-26 12:37  复件 ex4-1\ex4-1\search.cs

     文件       4535  2008-10-26 13:06  复件 ex4-1\ex4-1\ex4-1.csproj

     文件        464  2008-10-08 23:14  复件 ex4-1\ex4-1\Program.cs

     文件        945  2006-11-12 20:34  复件 ex4-1\ex4-1\Resources\Bold.PNG

     文件        965  2006-11-12 20:34  复件 ex4-1\ex4-1\Resources\Italic.PNG

     文件        953  2006-11-12 20:34  复件 ex4-1\ex4-1\Resources\Underline.PNG

     文件       1014  2008-11-01 11:18  复件 ex4-1\ex4-1\Resources\back.bmp

     文件       1074  2008-11-01 11:18  复件 ex4-1\ex4-1\Resources\fore.bmp

     文件       6995  2008-10-19 18:00  复件 ex4-1\ex4-1\search.Designer.cs

     文件       7172  2008-10-18 21:06  复件 ex4-1\ex4-1\replace.Designer.cs

     文件       5814  2008-10-18 21:06  复件 ex4-1\ex4-1\replace.resx

     文件       3883  2008-10-26 20:51  复件 ex4-1\ex4-1\childForm.cs

     文件       5814  2008-10-18 21:06  复件 ex4-1\ex4-1\search.resx

     文件        249  2008-10-08 23:14  复件 ex4-1\ex4-1\Properties\Settings.settings

     文件       1182  2008-10-08 23:14  复件 ex4-1\ex4-1\Properties\AssemblyInfo.cs

     文件       3840  2008-10-26 13:04  复件 ex4-1\ex4-1\Properties\Resources.Designer.cs

     文件       1101  2008-10-26 13:04  复件 ex4-1\ex4-1\Properties\Settings.Designer.cs

     文件       6928  2008-10-26 13:02  复件 ex4-1\ex4-1\Properties\Resources.resx

     文件       5632  2005-11-11 22:25  复件 ex4-1\ex4-1\bin\Debug\ex4-1.vshost.exe

     文件      49152  2008-11-01 15:38  复件 ex4-1\ex4-1\bin\Debug\ex4-1.exe

     文件      69120  2008-11-01 15:38  复件 ex4-1\ex4-1\bin\Debug\ex4-1.pdb

     文件         20  2008-10-26 18:15  复件 ex4-1\ex4-1\bin\Debug\label1

     文件        360  2008-11-01 15:38  复件 ex4-1\ex4-1\obj\ex4-1.csproj.FileList.txt

     文件       2495  2008-11-01 15:38  复件 ex4-1\ex4-1\obj\Debug\ex4_1.Form1.resources

     文件       2050  2008-10-26 13:05  复件 ex4-1\ex4-1\obj\Debug\ex4_1.Properties.Resources.resources

     文件      49152  2008-11-01 15:38  复件 ex4-1\ex4-1\obj\Debug\ex4-1.exe

     文件        180  2008-10-18 21:06  复件 ex4-1\ex4-1\obj\Debug\ex4_1.search.resources

............此处省略23个文件信息

评论

共有 条评论