how can I disable the enter keypress in a textbox?

Dec 8, 2011 at 3:59pm
I am trying to write a chat room in Dev C++ using the windows forms template. I have it basically working, but I would like to allow the user to press the "enter" key to do the same thing as pressing the button to post their text. I want to make sure this only happens when the one textbox has focus. Also, this should block the "\r\n" added to the textbox. How can I do this?
Last edited on Dec 8, 2011 at 4:01pm
Dec 8, 2011 at 4:14pm
I use visual studio, but hopefully the concept is the same/similar:

in the properties for the textbox double click on the 'keypress' field. This will create a function for whenever a key is pressed inside the textbox. I think the return key is 13, so use an if statement for when key pressed is 13 and then insert your code for whatever you want it to do.

Sorry if it's different in Dev c++
Dec 8, 2011 at 4:31pm
Unfortunately I don't think Dev c++ has a properties box. If it does I don't know how to access it.
Topic archived. No new replies allowed.