How to make NumericUpDown ReadOnly

I would like the numerical control updown not to be edited, or at least spin control should be disabled in Winforms. I tried to set the control to be read-only, but using the scroll values ​​the mouse changes. Please help me with this.

+4
source share
2 answers

Try the following to set the number up / down as read only:

numericUpDown1.ReadOnly = true;    
numericUpDown1.Increment = 0;

Hope this helps.

+8
source

Another alternative is to subclass NumericUpDownand override the methods DownButtonand UpButtonto return them earlier when set ReadOnly:

public override void DownButton()
{
   if(this.ReadOnly)
      return;

   base.DownButton();
}

public override void UpButton()
{
   if(this.ReadOnly)
      return;

   base.UpButton();
}

.

, ReadOnly , , .

+3

All Articles