public Form1()
{
InitializeComponent();
}
Private void cut ttoolstripmenuitem [click (object sender, EventArgs E)
{
richTextBox1.Cut();
}
Private void copy ctoolstripmenuitem [click (object sender, EventArgs E)
{
richTextBox1.Copy();
}
Private void paste ptoolstripmenuitem [click (object sender, EventArgs E)
{
richTextBox1.Paste();
}
Private void undo utoolstripmenuitem [click (object sender, EventArgs E)
{
richTextBox1.Undo();
}
Private void repeat rtoolstripmenuitem [click (object sender, EventArgs E)
{
richTextBox1.Redo();
}
Private void select atools stripmenuitem [click (object sender, EventArgs E)
{
richTextBox1.SelectAll();
}
private void toolStripStatusLabel2_Click(object sender, EventArgs e)
{
}
Private void auto wrap toolstripmenuitem [click (object sender, EventArgs E)
{
if (richTextBox1.WordWrap)
{
Auto wrap toolstripmenuitem.checked = false;
richTextBox1.WordWrap = false;
toolStripStatusLabel4.Text = "1";
toolStripStatusLabel6.Text = richTextBox1.TextLength.ToString();
}
Else
{
Auto wrap toolstripmenuitem.checked = true;
richTextBox1.WordWrap = true;
}
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
Toolstripstatuslabel2. Text = richtextbox1. Textlength. Tostring(); / / number of characters
Toolstripstatuslabel4. Text = richtextbox1. Lines. Length. Tostring(); / / line number
Toolstripstatuslabel6. Text = (richtextbox1. Selectionstart - richtextbox1. Getfirstcharindexofcurrentline()). Tostring(); / / number of columns with focus
}
private void richTextBox1_Click(object sender, EventArgs e)
{
Toolstripstatuslabel6. Text = (richtextbox1. Selectionstart - richtextbox1. Getfirstcharindexofcurrent line()). Tostring(); / / number of columns with focus
Int index = richtextbox1. Getfirstcharindexofcurrentline(); / / getfirstcharindexofcurrentline() index of the first character of the current line
//Getlinefromcharindex (index) the index line number of the specified location
Toolstripstatuslabel4. Text = (richtextbox1. Getlinefromcharindex (index) + 1). Tostring(); / / line number of focus
}
WinForm Notepad Preliminary implementation