📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//Download by http://www.codefans.net
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string fname;
bool f;
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = "请输入需要查找的字符串后,再单击<查找搜寻>钮: ";
}
private void btnFont_Click(object sender, EventArgs e)
{
if (fontDialog1.ShowDialog() == DialogResult.OK)
richTextBox1.SelectionFont = fontDialog1.Font;
}
private void btnColor_Click(object sender, EventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
richTextBox1.SelectionColor =colorDialog1.Color ;
}
private void btnItem_Click(object sender, EventArgs e)
{
if (f == false)
{
richTextBox1.SelectionBullet = true;
f = true;
}
else
{
richTextBox1.SelectionBullet = false;
f = false;
}
}
private void brnFind_Click(object sender, EventArgs e)
{
int strstart;
string str1="";
str1 = textBox1.Text;
strstart = richTextBox1.Find(str1);
if (strstart > 0)
{
richTextBox1.SelectionLength = str1.Length;
richTextBox1.SelectionStart = strstart;
richTextBox1.Focus();
}
else
{
label1.Text= "Not Find ! ......";
}
}
private void btnClear_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void btnOpen_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
fname = openFileDialog1.FileName;
richTextBox1.LoadFile(fname, RichTextBoxStreamType.RichText );
// 将开启对话框设定的文件名指定给fname
}
}
private void btnSave_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
fname = saveFileDialog1.FileName;
richTextBox1.SaveFile(fname, RichTextBoxStreamType.RichText );
}
}
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
System.Diagnostics.Process.Start (e.LinkText);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -