本帖最后由 gzm998128gzm 于 2013-02-18 17:24:36 编辑

解决方案 »

  1.   

            private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
            {            if (e.KeyCode == Keys.Enter)
                { 
                    richTextBox1.Text += "qwer";
                    richTextBox1.Select(richTextBox1.TextLength, 0);            }
            }
      

  2.   

    \r\n是换行        private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Return)
                {
                    richTextBox1.AppendText("\r\naaa");
                    e.Handled = true;
                }
            }
      

  3.   

    我是在第一行末尾打回车的 应该aaa出现在最中间啊  出现在最下面
      

  4.   

            private void richTextBox1_KeyUp(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Return)
                {
                    int index = richTextBox1.GetFirstCharIndexOfCurrentLine();
                    int line = richTextBox1.GetLineFromCharIndex(index);
                    String[] lines = richTextBox1.Lines;
                    lines[line] = "24324234234234";
                    richTextBox1.Lines = lines;
                }
            }
      

  5.   

    光标你可以Set的啊
            private void richTextBoxCh_KeyUp(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Return)
                {
                    int pos = richTextBoxCh.SelectionStart;
                    string str = richTextBoxCh.Text;                string str2 = str.Substring(0, pos) + "test" + str.Substring(pos);                richTextBoxCh.Text = str2;
                    richTextBoxCh.SelectionStart = pos ;                e.Handled = true;
                }
            }