help me to cheat with numericUpDown1_ValueChanged event
- by alex
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.