標籤:menuitem ons nes hang 技術 rto win charindex 複製
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記事本初步實現