textbox event handler?

i have a window form which have 3 textbox. I would like to ask for the coding when the user click the third textbox, it will sum up the value of textbox1 and textbox2 and display the total in textbox3. What event handler can be used in this case

Answer this question

textbox event handler?

  • stack

    You can use Click event for your textbox3. Code inside the click event would look something like:

    double value1, value2;

    if (!double.TryParse(textBox1.Text, out value1))

    {

    MessageBox.Show("Please enter numeric value in textBox1");

    return;

    }

    if (!double.TryParse(textBox2.Text, out value2))

    {

    MessageBox.Show("Please enter numeric value in textBox2");

    return;

    }

    double result = value1 + value2;

    textBox3.Text = result.ToString();


  • kmhawkes

    click event

    i cant find this in event properties....

    i only find this...

    private void textBox1_DoubleClick(object sender, System.EventArgs e)
    {

    }

    Is there anyway to solve it


  • RayMan55

    There's a MouseClicked event handler, but, this one is only raised when you really click it using the mouse.

    Have a look at the 'Enter' event of the textbox. This one is raised when the Textbox receives focus.


  • ping0506

    Thank you for both of you ...

    i tried both 'click' and 'enter', and finally i decided to use 'enter'....

    thank you..


  • colinrobinson

    Enter is indeed the preferred way, since it is raisend whenever the control receives focus, no matter how ... (by mouse, by keyboard; ... )


  • textbox event handler?