if you are using Visual Studio, click the lightening symbol in the
properties window on the right when the textbox is selected. This will show
all the evnts for that control, then find the one you want, keydown etc and
double click in the box next to it, and voila, creates the event, assigns it
and creates the method that will fire.
"dani kotlar" <da*********@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Thanks, I entered the line
textbox.KeyDown += inputTextBox_KeyDown;
and it works!
By the way, how do I get the designer (2.0 version) to generate it for
me?
Daniel wrote:
>Why you catching a SocketException? Would that code throw a socket error?
You said you wrote that event, did you subscribe it to the box yeah? If
you
used the designer to generate it this would be done for you
textbox.KeyDown += inputTextBox_KeyDown; //for example (.net 2.0 syntax)
Have you stuck a breakpoint in that code to see if that method fires. If
it
doesnt then its the reason above i would expect.
"dani kotlar" <da*********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googleg roups.com...
This seems to be a simple question:
How do I get the program to react after text was typed into a test box
and Enter was pressed?
I tried to write a KeyDown event. The program compiles and runs, but
when I enter text and press Return nothing happens. The debugger also
gets stuck in this point. Here is the KeyDown I wrote:
private void inputTextBox_KeyDown(object sender, KeyEventArgs
e)
{
try
{
if(e.KeyCode == Keys.Enter)
{
writer.Write("CLIENT>>" + inputTextBox.Text);
displayTextBox.Text +=
"\r\nCLIENT>>" + inputTextBox.Text;
inputTextBox.Clear();
}
}
catch(SocketException ioe)
{
displayTextBox.Text += "\nError writing object";
}
}
What is wrong?
Danny K