473,434 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

reading from text box

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

Oct 3 '06 #1
3 1988
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.googlegr oups.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

Oct 3 '06 #2
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.googlegr oups.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
Oct 3 '06 #3
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

Oct 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
8
by: Phil Slater | last post by:
I'm trying to process a collection of text files, reading word by word. The program run hangs whenever it encounters a word with an accented letter (like rôle or passé) - ie something that's not a...
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
1
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
2
by: Sabin Finateanu | last post by:
Hi I'm having problem reading a file from my program and I think it's from a procedure I'm using but I don't see where I'm going wrong. Here is the code: public bool AllowUsage() { ...
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
4
by: Jason Kumpf | last post by:
OK I've been staring at this code all day and still with everything I have tried I cannot figure out two problems I am having. Once is why the space limit for the directory I create in the code...
4
by: Amit Maheshwari | last post by:
I need to read text file having data either comma seperated or tab seperated or any custom seperator and convert into a DataSet in C# . I tried Microsoft Text Driver and Microsoft.Jet.OLEDB.4.0...
1
by: ChrisFrohlich | last post by:
ASP.NET 2.0 with Text DataTypes: I've got a similar question going in the SQL group, but I was wondering if anyone has successfully implemented reading/writing character data from a Text datatype...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.