Question

When I disabled Numeric UpDown control I want that user can still read its value. But I can't change Forecolor or Backcolor of that tool. I try to use ReadOnly property instead of Enabled/Disabled property but it doesn't worked either. How can I solve this problem?

Was it helpful?

Solution

I just tried via VS2005 and simple WinForms. I put in the EnableChanged event

private void numericUpDown1_EnabledChanged(object sender, EventArgs e)
{
   NumericUpDown nud = (NumericUpDown)sender;
   nud.BackColor = nud.Enabled ? Color.Yellow : Color.Red;
}

and added another button to the form to just swap its enabled state

private void button2_Click(object sender, EventArgs e)
{
   this.numericUpDown1.Enabled = ! this.numericUpDown1.Enabled;
}

If you create your own NumericUpDown class derived from the base NumericUpDown class and put it within the that, it will do for all instances of YOUR class used in your app without explicitly doing this color changing in every form.

OTHER TIPS

There is no way to achieve this goal with the frame work control. You can use custom draw to implement it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top