Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 10-Jan-13 23:20pm
Edited 10-Jan-13 23:28pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

This is how it can be done
 
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.
  Permalink  
Comments
vinayak chavan at 11-Jan-13 5:52am
   
no dear its not working total not comes on textbox 3
vinayak chavan at 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 at 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.
vinayak chavan at 11-Jan-13 5:53am
   
above i have made the code but not working
vinayak chavan at 11-Jan-13 6:03am
   
i need runtime total change in textbox 3 when user chnage value in textbox2
Rahul Rajat Singh at 11-Jan-13 6:11am
   
Its working for me, so either you are using wrong textbox ids or some other code is acting up. I really suggest you debug the code and problem will instantly come in front of you.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100