private void button1_Click_1(object sender, EventArgs e)
        {
         
            if (CheckBox1.Checked && listBox1.SelectedIndex<0)
            {
                MessageBox.Show("请选择一个用户", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string msg = "";
            if (CheckBox1.Checked)
                msg = "PRIV" + clientname + "|" + listBox1.SelectedItem.ToString() + "|";
            else
                msg = "CHAT" + clientname + "|";
            if (chatMsg.Text == "")
            {
                MessageBox.Show("说话内容不能为空", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            msg += chatMsg.Text;
            Byte[] outbytes = System.Text.Encoding.ASCII.GetBytes(msg.ToCharArray());
            ns.Write(outbytes, 0, outbytes.Length);
            chatMsg.Text = "";
            
        }
为什么我点发送之后聊天窗口没有显示啊。 
难道是我聊天窗口的属性有问题?

解决方案 »

  1.   

    发送窗口是chatMsg
    接收窗口是listBox1
    CheckBox1是选择私聊与否
    private void richTextBox1_TextChanged(object sender, EventArgs e)
            {
                richTextBox1.ScrollToCaret();
            }
    这是我接收窗口的代码   这样行吗?
      

  2.   

    up    是不是没socket出去啊
      

  3.   

    晕死!!编译的时候不能发送。debug后就能发送了。试了几次都是这样。不知道哪里搞错了!