说明文档一页纸,根本没提这个事。改成串口才能在超级终端里显示中文,但在普遍winfrom窗体的文本框里没显示。

解决方案 »

  1.   


    试试使用ASCII编码获得文字。.net默认是Unicode。
      

  2.   

    byte 数组转String 能支持中文吗?
      

  3.   

    //serialPort1.Encoding = System.Text.Encoding.GetEncoding("GB2312");//指定字符集,使之能发送中文试试这个。
      

  4.   

    各位好,我看过了 c#如何从串口获得扫描枪数据 http://bbs.csdn.net/topics/360058004
    但是不知道如何把串口数据显示到textbox中,谁能帮忙看看?
    谢谢!
      

  5.   

    void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
            {
                sb.Append(serialPort.ReadExisting());
                int index = sb.ToString().Length;
                if (index > 0)
                {
                    try
                    {
                        System.Windows.Forms.SendKeys.SendWait(sb.ToString(0, index) + "~");//将一个或多个按键消息发送到活动窗口,就如同在键盘上进行输入一样。
                    }
                    finally
                    {
                        sb.Remove(0, index);
                    }
                }
            }哪里不明白啦?