| mannsko wrote: |
|
code for :when save button is clicked all the text box fields are entered the data of the text box should be sent to the database through a stored procedure
| |
OK, open up the project in VS2008, highlight your textBox, find Properties on the right, On the top of that long box there is a button with a striking lightning. Click it. You will see events for the textBox. Find the event TextChanged. Name it in the textBox in the event dialog box. It could be tetxBox1_TextChanged. Close the event dialog box.
VS2008 will generate for you an event delegate textBox1_TextChanged in the code.
In that method you will have to detect the fact that the user entered the carriage return. You do the fllowing:
private void textbox1_TextChanged ( object sender, EventArgs ee)
{
string text = this.textBox1.Text;
if ( text.IndexOf (Environment.NewLine) != -1 )
{
// at this point your text is ready to be send down the pipe to Sql Server.
// the reason for this if statement is that the event will fire every time a letter was
// added or even removed. However when user hits CR, that's it.
// At this point you will also clear the textbox (after the text was send to Sql Server):
this.textBox1.Text = String.Empty;