private void textBox1_TextChanged(object sender, System.EventArgs e)
{       string temp=this.textBox1.Text ;
if(temp.Length >2)
{
if(temp.Substring(temp.Length-3,2)==@"\n")
{
temp.Remove (temp.Length -3,2);
temp+="\n";
this.textBox1 .Text =temp;
}
}
}
你可以用类似方法做个switch case

解决方案 »

  1.   

    你看看msdn里的应用吧,里面有一个自解压的程序,接压后的文件夹包含有关com口的编程的源码,里面有个文本筐,你看看是如何处理的
    ms-help://MS.MSDNQTR.2003FEB.2052/dnmag02/html/NETSerialComm.htm
      

  2.   

    实际上你完全可以自己解析的,用substring函数
      

  3.   

    private string RepX(Match m) {
    string str = m.ToString();
    string val = str.Substring(2);
    int i = System.Convert.ToInt32(val, 16);
    return ((char)i).ToString();
    }private void button1_Click(object sender, System.EventArgs e) {
    string s1 = @"a\nb\x63d"; //is you textbox.text
    string s2;

    s2 = Regex.Replace(s1, @"\\n", "\n");
    s2 = Regex.Replace(s2, @"\\x\d{2}", new MatchEvaluator(RepX)); MessageBox.Show(s2);
    }
      

  4.   

    注意此例是按正规的标准 \x 后面是16 进制来解析的,如果你的 \x 后面是十进制你可以将上面的 int i = System.Convert.ToInt32(val, 16);改成int i = int.Parse(val);