C#的记事本代码,要简单点的就好!
3个回答
展开全部
这是我做的一个简单的记事本,功能比较简单,觉得挺适合你的,代码在下面,如果有什么不懂得话可以百度HI我~~~
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 记事本
{
public partial class MdiChild : Form
{
public MdiChild()
{
InitializeComponent();
}
private void 剪切XToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Cut();
}
private void 复制CToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Copy();
}
private void 粘贴VToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Paste();
}
private void 颜色ToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog colordig = new ColorDialog();
DialogResult dlgresult;
dlgresult = colordig.ShowDialog();
if (dlgresult == DialogResult.OK)
richTextBox1.SelectionColor = colordig.Color;
}
private void 背景色ToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog ff = new ColorDialog();
DialogResult dlgresult;
dlgresult = ff.ShowDialog();
if (dlgresult == DialogResult.OK)
richTextBox1.BackColor = ff.Color;
}
private void 字体ToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog fontdig = new FontDialog();
DialogResult dlgresult;
dlgresult = fontdig.ShowDialog();
if (dlgresult == DialogResult.OK)
richTextBox1.SelectionFont = fontdig.Font;
}
private void 加粗ToolStripMenuItem1_Click(object sender, EventArgs e)
{
Font newfont = new Font(richTextBox1.SelectionFont, (richTextBox1.SelectionFont.Bold ? richTextBox1.SelectionFont.Style & ~FontStyle.Bold : richTextBox1.SelectionFont.Style | FontStyle.Bold));
richTextBox1.SelectionFont = newfont;
}
private void 斜体ToolStripMenuItem_Click(object sender, EventArgs e)
{
Font newfont=new Font(richTextBox1.SelectionFont,(richTextBox1.SelectionFont.Italic?richTextBox1.SelectionFont.Style&~FontStyle.Italic:richTextBox1.SelectionFont.Style|FontStyle.Italic));
richTextBox1.SelectionFont=newfont;
}
private void 下划线ToolStripMenuItem_Click(object sender, EventArgs e)
{
Font newfont = new Font(richTextBox1.SelectionFont, (richTextBox1.SelectionFont.Underline ? richTextBox1.SelectionFont.Style & ~FontStyle.Underline : richTextBox1.SelectionFont.Style | FontStyle.Underline));
richTextBox1.SelectionFont = newfont;
}
private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Cut();
}
private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Copy();
}
private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Paste();
}
private void 加粗ToolStripMenuItem2_Click(object sender, EventArgs e)
{
}
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 0.75f;
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 1f;
}
private void toolStripMenuItem4_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 1.5f;
}
private void toolStripMenuItem5_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 2f;
}
private void toolStripMenuItem6_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 3.0f;
}
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("IExplore", e.LinkText);
}
}
}
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 记事本
{
public partial class MdiChild : Form
{
public MdiChild()
{
InitializeComponent();
}
private void 剪切XToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Cut();
}
private void 复制CToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Copy();
}
private void 粘贴VToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Paste();
}
private void 颜色ToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog colordig = new ColorDialog();
DialogResult dlgresult;
dlgresult = colordig.ShowDialog();
if (dlgresult == DialogResult.OK)
richTextBox1.SelectionColor = colordig.Color;
}
private void 背景色ToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog ff = new ColorDialog();
DialogResult dlgresult;
dlgresult = ff.ShowDialog();
if (dlgresult == DialogResult.OK)
richTextBox1.BackColor = ff.Color;
}
private void 字体ToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog fontdig = new FontDialog();
DialogResult dlgresult;
dlgresult = fontdig.ShowDialog();
if (dlgresult == DialogResult.OK)
richTextBox1.SelectionFont = fontdig.Font;
}
private void 加粗ToolStripMenuItem1_Click(object sender, EventArgs e)
{
Font newfont = new Font(richTextBox1.SelectionFont, (richTextBox1.SelectionFont.Bold ? richTextBox1.SelectionFont.Style & ~FontStyle.Bold : richTextBox1.SelectionFont.Style | FontStyle.Bold));
richTextBox1.SelectionFont = newfont;
}
private void 斜体ToolStripMenuItem_Click(object sender, EventArgs e)
{
Font newfont=new Font(richTextBox1.SelectionFont,(richTextBox1.SelectionFont.Italic?richTextBox1.SelectionFont.Style&~FontStyle.Italic:richTextBox1.SelectionFont.Style|FontStyle.Italic));
richTextBox1.SelectionFont=newfont;
}
private void 下划线ToolStripMenuItem_Click(object sender, EventArgs e)
{
Font newfont = new Font(richTextBox1.SelectionFont, (richTextBox1.SelectionFont.Underline ? richTextBox1.SelectionFont.Style & ~FontStyle.Underline : richTextBox1.SelectionFont.Style | FontStyle.Underline));
richTextBox1.SelectionFont = newfont;
}
private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Cut();
}
private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Copy();
}
private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Paste();
}
private void 加粗ToolStripMenuItem2_Click(object sender, EventArgs e)
{
}
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 0.75f;
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 1f;
}
private void toolStripMenuItem4_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 1.5f;
}
private void toolStripMenuItem5_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 2f;
}
private void toolStripMenuItem6_Click(object sender, EventArgs e)
{
this.richTextBox1.ZoomFactor = 3.0f;
}
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("IExplore", e.LinkText);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询