WinForm Notepad Preliminary implementation

Source: Internet
Author: User





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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.