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 = "";
}
为什么我点发送之后聊天窗口没有显示啊。
难道是我聊天窗口的属性有问题?
{
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 = "";
}
为什么我点发送之后聊天窗口没有显示啊。
难道是我聊天窗口的属性有问题?
接收窗口是listBox1
CheckBox1是选择私聊与否
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
richTextBox1.ScrollToCaret();
}
这是我接收窗口的代码 这样行吗?