help me to cheat with numericUpDown1_ValueChanged event

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-05-18T12:26:59Z Indexed on 2010/05/18 12:30 UTC
Read the original article Hit count: 351

Filed under:
|

I have a Form and numericupdown control located on it. I want that in some conditions (_condition1) user cannot be able to change a value of numericupdown control. How can I do it ? I wrote some code but it works twice (double time).

class Form1 : Form { bool _condition1;

    int _previousValue;

    void numericUpDown1_ValueChanged(object sender, EventArgs e)
    {
           if(_condition1)
           {
                 numericUpDown1.Value = (decimal)_previousValue;
           }
           else
           {
                 _previousValue = (int)numericUpDown1.Value;
           }
    }

}

Control must be enable.

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms