winform記事本初步實現

來源:互聯網
上載者:User

標籤:全選   component   end   rto   cti   color   焦點   from   記事本   

 public Form1()        {            InitializeComponent();        }        private void 剪下TToolStripMenuItem_Click(object sender, EventArgs e)        {            richTextBox1.Cut();        }        private void 複製CToolStripMenuItem_Click(object sender, EventArgs e)        {            richTextBox1.Copy();        }        private void 粘貼PToolStripMenuItem_Click(object sender, EventArgs e)        {            richTextBox1.Paste();        }        private void 撤消UToolStripMenuItem_Click(object sender, EventArgs e)        {            richTextBox1.Undo();        }        private void 重複RToolStripMenuItem_Click(object sender, EventArgs e)        {            richTextBox1.Redo();        }        private void 全選AToolStripMenuItem_Click(object sender, EventArgs e)        {            richTextBox1.SelectAll();        }        private void toolStripStatusLabel2_Click(object sender, EventArgs e)        {                    }        private void 自動換行ToolStripMenuItem_Click(object sender, EventArgs e)        {            if (richTextBox1.WordWrap)            {                自動換行ToolStripMenuItem.Checked = false;                richTextBox1.WordWrap = false;                toolStripStatusLabel4.Text = "1";                toolStripStatusLabel6.Text = richTextBox1.TextLength.ToString();            }            else            {                自動換行ToolStripMenuItem.Checked = true;                richTextBox1.WordWrap = true;            }        }        private void richTextBox1_TextChanged(object sender, EventArgs e)        {            toolStripStatusLabel2.Text = richTextBox1.TextLength.ToString();//字元數            toolStripStatusLabel4.Text = richTextBox1.Lines.Length.ToString();//行號                       toolStripStatusLabel6.Text = (richTextBox1.SelectionStart - richTextBox1.GetFirstCharIndexOfCurrentLine()).ToString();//焦點所在列數        }        private void richTextBox1_Click(object sender, EventArgs e)        {            toolStripStatusLabel6.Text = (richTextBox1.SelectionStart - richTextBox1.GetFirstCharIndexOfCurrentLine()).ToString();//焦點所在列數                        int index = richTextBox1.GetFirstCharIndexOfCurrentLine();//GetFirstCharIndexOfCurrentLine()當前行第一個字元的索引            //GetLineFromCharIndex(index)指定位置的索引行號            toolStripStatusLabel4.Text = (richTextBox1.GetLineFromCharIndex(index) + 1).ToString();//焦點所在行號        }

 

winform記事本初步實現

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.