⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 find.cs

📁 C#做的一个文本编辑器
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace myTest
{
	/// <summary>
	/// find 的摘要说明。
	/// </summary>
	public class find : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label Label;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Button sureButton;
		private System.Windows.Forms.Button concelButton;
		myText MainForm1;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public find(myText form1)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			MainForm1 = form1;
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(find));
			this.Label = new System.Windows.Forms.Label();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.sureButton = new System.Windows.Forms.Button();
			this.concelButton = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// Label
			// 
			this.Label.BackColor = System.Drawing.Color.SkyBlue;
			this.Label.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.Label.Location = new System.Drawing.Point(8, 24);
			this.Label.Name = "Label";
			this.Label.Size = new System.Drawing.Size(112, 24);
			this.Label.TabIndex = 0;
			this.Label.Text = "请输入关键字";
			this.Label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// textBox1
			// 
			this.textBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.textBox1.Location = new System.Drawing.Point(128, 24);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(160, 26);
			this.textBox1.TabIndex = 1;
			this.textBox1.Text = "";
			// 
			// sureButton
			// 
			this.sureButton.Image = ((System.Drawing.Image)(resources.GetObject("sureButton.Image")));
			this.sureButton.Location = new System.Drawing.Point(24, 64);
			this.sureButton.Name = "sureButton";
			this.sureButton.Size = new System.Drawing.Size(80, 24);
			this.sureButton.TabIndex = 2;
			this.sureButton.Click += new System.EventHandler(this.sureButton_Click);
			// 
			// concelButton
			// 
			this.concelButton.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.concelButton.Image = ((System.Drawing.Image)(resources.GetObject("concelButton.Image")));
			this.concelButton.Location = new System.Drawing.Point(200, 64);
			this.concelButton.Name = "concelButton";
			this.concelButton.Size = new System.Drawing.Size(72, 24);
			this.concelButton.TabIndex = 3;
			this.concelButton.Click += new System.EventHandler(this.concelButton_Click);
			// 
			// find
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(314, 103);
			this.Controls.Add(this.concelButton);
			this.Controls.Add(this.sureButton);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.Label);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "find";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "find";
			this.ResumeLayout(false);

		}
		#endregion

		private void sureButton_Click(object sender, System.EventArgs e)
		{
			if(textBox1.Text.Length!=0)//如果查找字符串不为空,调用主窗体查找方法
				MainForm1.FindRichTextBoxString(textBox1.Text);//上步增加的方法
			else
				MessageBox.Show("查找字符串不能为空","提示",MessageBoxButtons.OK);
		}

		private void concelButton_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -