Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 3 textboxes on windows form:

1 st textbox have static value :100

and in 2nd textbox user type int value

when user enter value in 2nd textbox on change event

i need runtime total of this 2 textbox value in textbox3

iam new in c#.

thanks in advance
Posted
Updated 10-Jan-13 23:28pm
v2

This is how it can be done

C#
private void textBox2_TextChanged(object sender, EventArgs e)
       {
           double val1;
           double val2;

           bool validOne = Double.TryParse(textBox1.Text, out val1);
           bool validTwo = Double.TryParse(textBox2.Text, out val2);

           if (validOne && validTwo)
           {
               double result = val1 + val2;
               textBox3.Text = result.ToString();
           }
       }


I strongly suggest you get acquainted your self with technology and programming methodology. This is a very basic task and you should have done it yourself.
 
Share this answer
 
Comments
Master Vinu 11-Jan-13 5:52am    
no dear its not working total not comes on textbox 3
Master Vinu 11-Jan-13 5:52am    
private void textBox5_TextChanged(object sender, EventArgs e)
{
double val1;
double val2;

bool validOne = Double.TryParse(txtTvalidqty.Text, out val1);
bool validTwo = Double.TryParse(textBox5.Text, out val2);

if (validOne && validTwo)
{
double result = val1 + val2;
txtAutoNo.Text = result.ToString();
}
}
Rahul Rajat Singh 11-Jan-13 5:54am    
are you sure you are entering valid double types as input. Why don't you debug the code to see what is wrong.
Master Vinu 11-Jan-13 5:53am    
above i have made the code but not working
Master Vinu 11-Jan-13 6:03am    
i need runtime total change in textbox 3 when user chnage value in textbox2
Hi friend

double i,j,k; //define these variable on class level.
then take the static textbox value on form load event.

i=convert.todouble(textbox1.text);

then on textbox2 text changed event...

j=convert.todouble(textbox2.text);
k= i+j;
textbox3.text=k.tostring();

but friend for proper output you have to run textbox2 text changed event properly and as per development professional i think you have proper knowledge of text changed event mechanism.

i think its help you.
thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900