c#实现记事本功能

这篇博客详细介绍了如何使用C#语言创建一个简单的记事本应用程序,包括新建、打开、保存、另存为、字体颜色选择、查找和替换等功能。通过创建多个窗体类如Form1、Form2和Form3,实现了文本编辑、查找和替换的操作,并提供了源码下载链接。
摘要由CSDN通过智能技术生成

form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Editor
{
    public partial class Form1 : Form
    {
        string filename = "";           //定义并初始化下文的文件名
        public Form1()
        {
            InitializeComponent();
            //初始化定时器
            timer1.Enabled = true;      //定时器的可见性
            timer1.Interval = 1000;     //定时器的时间间隔设置为1000ms
            this.toolStripStatusLabel1.Text = "系统当前时间:" + DateTime.Now.ToString();
        }

        private void toolStripMenuItem6_Click(object sender, EventArgs e)
        {
            //点击此选项,关闭窗口并退出程序
            this.Close();
            Application.Exit();
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            //新建选项
            richTextBox1.Clear();                       //清空丰富文本区
            filename = "";                              //开始的文件名为空
            this.Text = "无标题-EditorPrimer";          //初始化文件标题
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            //打开文件选项,调用openFile对话框
            openFileDialog1.Filter = "文本文件 | *.txt";        //设置文件类型过滤器
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值