
Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
but if I use textbox, it will accept any non-numeric characters.
"Bob Powell [MVP]" <bob@_spamkiller_.bobpowell.net> ¼¶¼g©ó¶l¥ó·s»D:OFj%23ajHoGHA.4352@TK2MSFTNGP02.phx.gbl...
> Just use a text box!
>
>> How to hide the numericUpDown control's up and down arrows?
>>
>> I only want the numeric textbox, but numericUpDown has up and down arrow
>> is not my want, how can I hide it?
Claes Bergefall - 06 Jul 2006 15:57 GMT
Public Class TextBoxEx
Inherits TextBox
Private Const ES_NUMBER As Integer = &H2000
Protected Overrides ReadOnly Property CreateParams() As
System.Windows.Forms.CreateParams
Get
Dim params As CreateParams = MyBase.CreateParams
params.Style = params.Style Or ES_NUMBER
Return params
End Get
End Property
Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As
Boolean
If keyData = (Keys.Shift Or Keys.Insert) OrElse keyData =
(Keys.Control Or Keys.V) Then
Dim data As IDataObject = Clipboard.GetDataObject
If data Is Nothing Then
Return MyBase.ProcessCmdKey(msg, keyData)
Else
Dim text As String =
CStr(data.GetData(DataFormats.StringFormat, True))
If text = String.Empty Then
Return MyBase.ProcessCmdKey(msg, keyData)
Else
For Each ch As Char In text.ToCharArray
If Not Char.IsNumber(ch) Then
Return True
End If
Next
Return MyBase.ProcessCmdKey(msg, keyData)
End If
End If
Else
Return MyBase.ProcessCmdKey(msg, keyData)
End If
End Function
End Class
/claes
> but if I use textbox, it will accept any non-numeric characters.