vendredi 13 mars 2015

In multiline textbox, my cursor automatically goes to next line

I am making a messenger application using winForms. So when I type a message in the sender's text box and press enter, the message gets delivered but the cursor on my text box automatically goes to the next line for the first time. And then it stays there for all the messages I type and send. I am using a simple keypress event for enter button which uses return. What can the problem be? The code is as follows:



private void txtChatOperatorMsg_KeyPress (object sender, KeyPressEventArgs e) {

if (e.KeyChar == (char) Keys.Return) {
pushToClientAndEmpty (txtChatOperatorMsg.Text);
}

}

private void pushToClientAndEmpty (string message) {
operatorgetset = message;
Thread operatorChatThread = new Thread (new ThreadStart (newThreadOperatorChat));
operatorChatThread.Start ();
txtChatOperatorMsg.Clear();
}

string operatorgetset {get;set;}

private void newThreadOperatorChat () {

SetText (operatorgetset);
}

Aucun commentaire:

Enregistrer un commentaire