fattumsdad
asked on
Accepting Returns
I have a multiline text box followed by a command button. When the command button is pressed, it takes the text in the multiline box and sends it over a LAN (net send). Is there a way to accomplish this same task, by pressing ENTER in the text box after the message is typed?
Is this a Windows app or web app?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Do I have to set any specific properties on txtMessage (the multiline text box)? None of the above code is working... when I press enter, it just puts me to the next line on the text box. I tried AcceptsReturn true and false... neither work :(
You need to register your function with the text box's keyup or keypress event. For example:
to catch keypress:
TextBox tb...
// this is an event set to call your delegate
tb.KeyPress += new KeyPressEventHandler(tb_Ke yPress);
...
//This was coppied from w_shaila's post
private void tb_KeyPress(object sender, System.Windows.Forms.KeyPr essEventAr gs e)
{
if (e.KeyChar == (char)13)
{
MessageBox.Show("Test");
}
}
to catch keypress:
TextBox tb...
// this is an event set to call your delegate
tb.KeyPress += new KeyPressEventHandler(tb_Ke
...
//This was coppied from w_shaila's post
private void tb_KeyPress(object sender, System.Windows.Forms.KeyPr
{
if (e.KeyChar == (char)13)
{
MessageBox.Show("Test");
}
}