zoukankan      html  css  js  c++  java
  • 将richTextBox中的内容写入txt文件发现不换行(解决方法),在richTextBox指定位置插入文字

           string pathname = dt.ToString().Replace(":", "");

           string str = richTextBoxResult.Text;

           str = str.Replace(" ", " ");     //关键

           File.AppendAllText(@"D:" + pathname + ".txt", str, Encoding.Default);       //将文字附加在原有的text文件末尾

     

       private void IndividualMessage_TextChanged(object sender, EventArgs e) //光标随输入移动

       {

                 this.IndividualMessage.SelectionStart = ShowMessage.TextLength;

                 this.IndividualMessage.ScrollToCaret();

                 //richTextBox1.Focus();   //此方法不如上边的好

                 //richTextBox1.Select(richTextBox1.Text.Length, 0);

                 //richTextBox1.ScrollToCaret();

       }

      在光标处插入内容:

           int startIndex = FileData.SelectionStart;  //获取richTextBox控件光标位置

           FileData.Text = FileData.Text.Insert(startIndex, content);//将content内容插入到当前位置

  • 相关阅读:
    Stepping Number
    Replace String
    String Permutation
    Clock Angle
    Keypad Permutation
    Replace Words
    1、奉加微 PHY6202 Get started
    Python3 修改二进制文件
    Google Fast Pair
    python 校验 BLE resolvable private address
  • 原文地址:https://www.cnblogs.com/zhanglei93/p/4762041.html
Copyright © 2011-2022 走看看