Click here to Skip to main content
13,864,078 members
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 22 Mar 2010
Licenced CPOL

Multiple Base Number Editor

, 22 Mar 2010
Rate this:
Please Sign up or sign in to vote.
A Windows Forms editor for editing number on bases binary, octal, decimal and hexadecimal


My initial motivation to write this component came after I was writing a component to support decimal and hexadecimal editing number at work. When I searched for some control or code on the internet, I realized that there was almost nothing like what I was looking for. Probably few people really need to enter numbers in base such as binary, octal or hexadecimal, but here we go.

Initially, my intent was to show the work and the code that I developed, but besides the code is not really long describing it in an article seems boring and unnecessary extensive. So this article is just to show the controls features and if the reader desires, he can download the source code or the assembly.


This code was written using Visual Studio 2008 Express Edition and requires .NET Framework 3.5. Assembly verification was done using Microsoft's FxCop. Code Documentation files were generated using Doxygen.

Using the Code

The MultipleBaseNumberEditor is a Windows Forms component that extends a System.Windows.Forms.UserControl and defines an editor that allows editing a number in any of these bases: binary, octal, decimal or hexadecimal. To use MultipleBaseNumberEditor in your project, you can either add the source code MultiBaseNumberEditor.cs to your solution or add the numbersEditors assembly reference. Adding the source code to the project requires that the project be compiled once before it appears on Visual Studio's Toolbox (under your projects tab).

It is also possible to register the assembly in GAC. For that, follow the instructions found in this link:

If the assembly is not registered, the control will not appear in .NET Framework Components when trying to add it to the toolbox. To add it to the toolbox manually without registering in GAC, click on browse and select the numbersEditors.dll.

To add the MultipleBaseNumberEditor component manually through Choose Toolbox Items, right click on Toolbox area and select "Choose Items", then click on "Browse...", find the numbersEditors.dll and click on Open. The component will appear in the list as shown in Figure 1. Make sure the component is checked, then click ok, the component shall appear on Toolbox.


Figure 1: Adding MultipleBaseNumberEditor component to Project

Drop the MultipleBaseNumberEditor from the Toolbox into a form on designer, see Figure 2. Check out the MultipleBaseNumberEditor properties on Properties view (Figure 3).
Besides most common properties from a Control, I list below the properties specifically from MultiBaseNumberEditor:

  • Base
  • Value
  • Minimum
  • Maximum
  • DisplayBaseChooserButton
  • BaseChooserStyle
  • ConfigBinary
  • ConfigOctal
  • ConfigDecimal
  • ConfigHexadecimal
  • DisplayAllBaseConversions


Figure 2: Dropping the MultipleBaseNumberEditor on the Form


Figure 3: Check out the properties on Properties view

Base is of type BaseNumber. The current defined bases are defined as:

public enum BaseNumber {

Value is an unsigned long. The control does not support negative values.

Minimum and Maximum define the limits Value can be.

Use the DisplayBaseChooserButton to show or hide the base chooser button. With the chooser button, the control allows the user to click and select which base he wants that number to be displayed.

The BaseChooserStyle defines the chooser button style. It can be a simple button or a drop-down list.

public enum BaseChooserStyle {

The ConfigBinary, ConfigOctal, ConfigDecimal and ConfigHexadecimal are settings specifically to each base number allowing the user sets if control should display prefix, suffix and if it should padleft with '0' character.

The MultipleBaseNumberEditor provides a default tooltip that within prints the current value in all available formats. To turn that tooltip on or off, set the DisplayAllBaseConversions.

The control provides the events, besides those inherited from UserControl:

public event EventHandler ValueChanged;   // Occurs when Value changes
public event EventHandler BaseChanged;    // Occurs when the base number changes

In Figure 4, it shows the MultipleBaseNumberEditor into a form with different settings.


Figure 4: A sample view

Also, this assembly is CLS Compliance (for more information about CLS Compliance:

Future Work

  • This control extends a UserControl. It could extend a TextBox. One of the challenges of extending from TextBox is how to draw or add the other controls added here to select the base (that can be a button or combo).
  • A similar control to work with large byte arrays, displaying groups in any of the chosen bases.
  • Possibility to extend this control to any base number editor (I wonder what would be the purpose). Possibility to add more features.
  • Provides more flexibility allowing what base the control will display and the user can select.


  • 22nd March, 2010: Initial post


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


About the Author

Software Developer
Brazil Brazil
Software Developer and Gamer and Dancer. Computer Science Graduated at Pontifical Catholic University of Belo Horizonte, MG, Brazil. Software Architect student at IGTI. Over 12000 hours of software development experience in many Technologies including: languages (C#, C++, VB.Net, Java, Delphi, Javascript, HTML, SQL); platforms (.Net Framework 1.1, 2, 3.5, 4); databases (Oracle, MS SqlServer); GIS applications (ESRI ArcGIS 9.2, 10); IDE (Visual Studio 2005, 2008, 2010, 2012, Delphi 7, 2006, Eclipse, Adobe Flash Builder 4 for Flex, Qt); Tools (Team Foundation, Perforce, Git, SVN, Starteam, SourceSafe, Winmerge, Doxygen, Notepad++, WireShark); Building web and desktop applications.

I'm more confortable and efficient coding in C#. I believe one should be always searching to overcome oneself.

You may also be interested in...

Comments and Discussions

GeneralInvalid Pin
Doncp24-Mar-10 13:29
memberDoncp24-Mar-10 13:29 
GeneralParabéns Pin
Ivo Closs22-Mar-10 17:21
memberIvo Closs22-Mar-10 17:21 
GeneralRe: Parabéns Pin
Ramon.Pinho23-Mar-10 15:19
memberRamon.Pinho23-Mar-10 15:19 
GeneralCalc.exe Pin
AspDotNetDev22-Mar-10 11:59
protectorAspDotNetDev22-Mar-10 11:59 
GeneralRe: Calc.exe Pin
Ramon.Pinho22-Mar-10 14:35
memberRamon.Pinho22-Mar-10 14:35 
GeneralSomething similar Pin
Paw Jershauge22-Mar-10 11:32
memberPaw Jershauge22-Mar-10 11:32 
GeneralRe: Something similar Pin
Ramon.Pinho22-Mar-10 15:37
memberRamon.Pinho22-Mar-10 15:37 
GeneralRe: Something similar Pin
Paw Jershauge23-Mar-10 1:22
memberPaw Jershauge23-Mar-10 1:22 
GeneralInvalid Pin
Doncp22-Mar-10 9:17
memberDoncp22-Mar-10 9:17 
AnswerRe: Invalid [modified] Pin
Ramon.Pinho22-Mar-10 15:08
memberRamon.Pinho22-Mar-10 15:08 
GeneralRe: Invalid Pin
Doncp23-Mar-10 7:17
memberDoncp23-Mar-10 7:17 
GeneralRe: Invalid [modified] Pin
elderdo25-Mar-16 11:08
memberelderdo25-Mar-16 11:08 

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

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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190214.1 | Last Updated 22 Mar 2010
Article Copyright 2010 by Ramon.Pinho
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid