Click here to Skip to main content
Click here to Skip to main content

NumericUpDown with correct read-only behavior

, 10 Nov 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
A simple article showing another bug in .NET Framework 2.0.


When writing a simple application, I needed one of the numeric boxes to be read only, so I just changed the ReadOnly property of NumericUpDown to true. But after a while, I noticed that I can change the value in it, not by typing, but by using the up and down buttons.


To save people time, I posted this article presenting a simple and fast solution to the problem:

public class FixedNumericUpDown : NumericUpDown
    public override void DownButton()
        if (ReadOnly)

    public override void UpButton()
        if (ReadOnly)



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Poland Poland
Hi to all.
I’m a software developer who works in a small company. I started programming when I was 10 (or less, can't remember) on not mine C64 – those were the good times :P Now I’m coding mainly in C# / C++, but my favorite language is C.

Comments and Discussions

GeneralMy vote of 5 PinmemberMember 864580517-Jul-13 6:05 
GeneralMy vote of 4 PinmemberToli Cuturicu19-Aug-10 6:14 
GeneralMight be even better PinmemberMillionsterNutzer21-May-10 11:05 
GeneralNumericUpDown.Increment = 0; PinmemberEugene Goryachev11-Apr-08 1:10 
GeneralFix without replacing the control Pinmemberlos.12-Jun-07 23:32 
GeneralRe: Fix without replacing the control PinmemberLemuel.Adane15-May-09 2:20 
Generaldisable updown-control Pinmemberjls1716-Nov-06 8:41 
AnswerRe: disable updown-control Pinmemberdr4cul416-Nov-06 22:27 
Generalcode style opinion PinmemberTornacious14-Nov-06 9:17 
QuestionMore readable? Pinmembernurgling10-Nov-06 7:04 
AnswerRe: More readable? PinmemberMarc Leger10-Nov-06 9:33 
AnswerRe: More readable? Pinmemberdr4cul411-Nov-06 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 10 Nov 2006
Article Copyright 2006 by dr4cul4
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid