0

I have a Textbox in Windows form and i want to do some calculation when user enter value . But Problem is that when my form load the Textbox_TextChange event fire because binding source fill 0 in the text box. So How can i do that .

Many thanks

A.Goutam
  • 3,422
  • 9
  • 42
  • 90
  • I don't really understand your problem... You need to get your calculations done, why does it matter if initial value is 0? Aren't you going to change it? Please, post some code. – Nikita Silverstruk Mar 11 '13 at 19:56

1 Answers1

0

One way is adding a boolean field and set it to true:

class Form1{
    bool firstTime = true;
    .
    .
    .
}

Then in your Textbox_TextChange method, only do the calculations when firstTime is false:

void Textbox_TextChange(object sender, EventArgs e)
{
    if(!firstTime)
    {
        //do calculations
    }
    firstTime = false;
}

So when you do the binding, which is the first time the text changes, the calculations won't be executed.

Forte L.
  • 2,772
  • 16
  • 25
  • but problem is that when form load binding source fill all values so that time how can i manage that – A.Goutam Mar 11 '13 at 17:49