• 大小: 300KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: C#
  • 标签: windows  form  .记事本C#  

资源简介

windows form窗体控件编写的记事本,具有各种记事本的相关功能,例如查找,替换,打印,页面设置,保存等功能,以及常规的复制,黏贴功能。是学习windows form 窗体编程的基础实验

资源截图

代码片段和文件信息

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 Text
{
    public partial class Find : Form
    {
        Form1 f1 = new Form1();
        public Find(Form1 fm)
        {
            f1 = fm;
            InitializeComponent();
        }

        private void Find_Load(object sender EventArgs e)
        {
            radioButton2.Checked = true;
        }

        private void button1_Click(object sender EventArgs e)
        {


            if (radioButton2.Checked == true)
            {
                down(f1.richTextBox1 this.textBox1.Text checkBox1.Checked);
                f1.richTextBox1.Focus();
            }
            else if (radioButton1.Checked == true)
            {
                up(f1.richTextBox1 this.textBox1.Text checkBox1.Checked);
                f1.richTextBox1.Focus();
            }



        }


        //向下查找
        public void down(RichTextBox text string test bool check)
        {
            string strDown = ““;
            int intCount = 0i=0;
            if(check==false)  //不区分大小写
            {
                if (text.SelectedText.ToUpper() == test.ToUpper())   //如果选中的文本等于需要替换的文本
                {

                    //从光标所在位置后一位开始截取后面的所有字符
                    strDown = text.Text.Substring(text.Selectionstart + 1 text.Text.Length - (text.Selectionstart+1));  
                }
                else
                {

                    //从光标所在位置开始截取后面的所有字符
                    strDown = text.Text.Substring(text.Selectionstart text.Text.Length - text.Selectionstart);
                }
                
            }
            else if (check == true)   //区分大小写
            {
                if (text.SelectedText == test)  //如果选中的文本等于需要替换的文本
                {

                    //从光标所在位置后一位开始截取后面的所有字符
                    strDown = text.Text.Substring(text.Selectionstart + 1 text.Text.Length - (text.Selectionstart+1));
                }
                else
                {

                    //从光标所在位置开始截取后面的所有字符
                    strDown = text.Text.Substring(text.Selectionstart  text.Text.Length - text.Selectionstart);
                }
            }
            intCount = text.Text.Length - strDown.Length;  //存放除截取的字符数以外的字符数

             // i + test.Length(要查找的字符的长度) 的长度不得大于截取字符数的长度
            for (i = 0; i+test.Length <= strDown.Length ; i++) 
            {
                if (check == true)  //区分大小写
                {
                    if (strDown.Substring(i test.Length) == test)  //截取的字符等于要查找的字符
                    {
                        text.Selectionstart = i+intCount;   //设置光标的起始位置
                        text.SelectionLength = test.Length;   //设置文本的选定字符数
                        return;
                    }
                }
                els

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-03-06 23:53  Text\
     文件        6793  2017-03-06 23:47  Text\QQ截图20170306234653.jpg
     文件       21148  2017-03-06 23:53  Text\QQ截图20170是.jpg
     目录           0  2017-03-06 23:52  Text\Text\
     文件        6579  2017-03-06 23:00  Text\Text\Find.Designer.cs
     文件        6656  2017-03-06 23:36  Text\Text\Find.cs
     文件        7764  2017-03-06 22:58  Text\Text\Find.resx
     文件       21221  2017-03-07 15:08  Text\Text\Form1.Designer.cs
     文件        4609  2017-03-07 15:08  Text\Text\Form1.cs
     文件        6825  2017-03-07 15:08  Text\Text\Form1.resx
     文件        2903  2017-03-06 23:57  Text\Text\Info.Designer.cs
     文件         469  2017-03-06 23:56  Text\Text\Info.cs
     文件        6344  2017-03-06 23:56  Text\Text\Info.resx
     文件         485  2017-03-01 11:06  Text\Text\Program.cs
     目录           0  2017-03-06 21:17  Text\Text\Properties\
     文件        1358  2017-03-01 10:01  Text\Text\Properties\AssemblyInfo.cs
     文件        3685  2017-03-06 23:53  Text\Text\Properties\Resources.Designer.cs
     文件        6769  2017-03-06 23:53  Text\Text\Properties\Resources.resx
     文件        1089  2017-03-01 10:01  Text\Text\Properties\Settings.Designer.cs
     文件         249  2017-03-01 10:01  Text\Text\Properties\Settings.settings
     文件        6543  2017-03-06 23:32  Text\Text\Replace.Designer.cs
     文件        7282  2017-03-06 23:45  Text\Text\Replace.cs
     文件        7567  2017-03-06 23:32  Text\Text\Replace.resx
     目录           0  2017-03-06 23:53  Text\Text\Resources\
     文件        6793  2017-03-06 23:52  Text\Text\Resources\QQ截图20170306234653.jpg
     文件        6793  2017-03-06 23:47  Text\Text\Resources\QQ截图201703062346531.jpg
     文件       21148  2017-03-06 23:53  Text\Text\Resources\QQ截图20170是.jpg
     文件        5186  2017-03-06 23:56  Text\Text\Text.csproj
     文件        8916  2017-03-04 14:39  Text\Text\ZiTi.Designer.cs
     文件        2769  2017-03-04 16:53  Text\Text\ZiTi.cs
     文件        5817  2017-03-04 14:39  Text\Text\ZiTi.resx
............此处省略61个文件信息

评论

共有 条评论