473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

NumericUpDown control

It is possible to format the numeric value of the NumericUpDown control

For example : display numbers in 2 digits, instead of 1 display 01, 0
-> 00 , 9 -> 09

Any idea

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

Nov 21 '05 #1
2 3670

Looks like the control only offers Hexadecimal, DecimalPlaces, and
ThousandsSeparator properties to control the format, not custom
formats.

You can probably subclass the control, add a Format property, and
override the UpdateEditText method to support a custom format like you
want.

However, since the ParseEditText property is not declared as
overridable, you can not add the logic needed to parse a totally
custom format--the format must be compatible with the default
Decimal.Parse() method.

If you do need an incompatible format, then I think the only option is
to create an entirely new NumericUpDown control that inherits
UpDownBase. It's a shame that so many of the windows controls methods
are not declared overridable--makes extending them difficult.

HTH,

Sam
On Thu, 23 Dec 2004 16:34:10 +0100, bnob <bn**@bluewin.ch> wrote:
It is possible to format the numeric value of the NumericUpDown control

For example : display numbers in 2 digits, instead of 1 display 01, 0
-> 00 , 9 -> 09

Any idea


Nov 21 '05 #2
Easy. Just Overrides Text property

Public Class myNumericUpDown
Inherits System.Windows.Forms.NumericUpDown

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

#End Region

Public Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
If Value.Length = 1 Then
MyBase.Text = "0" + Value
Else
MyBase.Text = Value
End If
End Set
End Property
End Class

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
0
by: Koert | last post by:
Hi, In the NumericUpDown control I have to detect that Tab was pressed so I have overroden the PreProcessMessage function. In for example the DateTimePicker this works fine but not in the...
1
by: Tantra Veda | last post by:
Hello C# gurus, I have a question about finding cursor position in NumericUpDown control. On my form I have a numericUpDown control with 2 decimal places. I want to increment value in the numeric...
10
by: Bonj | last post by:
I'm using a number of NumericUpDown controls on my form, which controls printer settings such as number of pages. However I want to override one of the default behaviours of the control, namely...
0
by: Koert | last post by:
Hi In the NumericUpDown control I have to detect that Tab was pressed so I have inherited the NumericUpDown and overroden the PreProcessMessage function. In the DateTimePicker (for example) this...
3
by: abc my vclass | last post by:
My win-form have many numericupdown controls to applied. But numericupdown control don't like textbox, text box control can automatic selected text when got focus. Is there any method can let me...
4
by: illegal.prime | last post by:
Hey all, I have a NumericUpDown control on a Panel or potentially a Form that have AutoScroll enabled. When the NumericUpDown is active I would like the Form/Panel/whatever not to scroll when I...
5
by: Len Weltman | last post by:
I am trying to pass a NumericUpDown object into a class method using Visual Studio 2005, but the control type is not found in Intellisense and the type declaration is flagged as an error. Here...
2
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello experts, I posted a disturbing question in here:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.