473,508 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Show Numeric keypad only for textbox containing phone number

15 New Member
I have a text box and it can contain only numbers. Similar to a phone number text box while adding a new contact. Programatically how can we open only the numeric keypad instead of both text/numeric keypad.

By this the user cannot enter text at anytime. Though validation for symbols can be made later.
Can you provide a code snippet for opening only a numeric keypad to enter numbers only for the text box.
Apr 5 '10 #1
10 18151
tlhintoq
3,525 Recognized Expert Specialist
This has nothing to do with what keypad you open.
The textbox has a .KeyPress event.
You write a method for that event (a handler) that checks if the key just pressed was a number or not. If it was a number you allow it. If it wasn't, you throw it away.

This is VERY common and I'm sure a Google for "C# numeric textbox" will get you a dozen examples.
Apr 5 '10 #2
tlhintoq
3,525 Recognized Expert Specialist
There is also a tutorial for making your own on-screen numeric keypad if you want to give it a whirl.
This tutorial for a cash register does exactly that: It makes a virtual numeric keyboard.
Apr 5 '10 #3
gopishk
15 New Member
The validation of entering numbers is already done as:

Expand|Select|Wrap|Line Numbers
  1. void textbox_phoneNumber_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
  2.         {
  3.             //Ignore if not 0-9 or backspace char
  4.             if ((e.KeyChar < '0' || e.KeyChar > '9') && (e.KeyChar != '\b'))
  5.             {
  6.                 e.Handled = true;
  7.             }
  8.         }
But i want only the numeric virtual keypad to be seen on screen, when focus is on this textbox..Please help me with a method for it. Iam very new to C#.

thanks in advance,
Gopish
Apr 5 '10 #4
tlhintoq
3,525 Recognized Expert Specialist
But i want only the numeric virtual keypad to be seen on screen,
What do you be "the" onscreen numeric keypad? There isn't one that ships in Windows. Did you make one of your own? Did you get a custom control from some other source?

Win7 has an option to turn on the number pad as part of it's fullsize keyboard
http://malektips.com/windows-7-on-sc...d-num-pad.html

Otherwise you can make the numeric keypad that is in my tutorial that I pointed you to and use that.
Apr 5 '10 #5
gopishk
15 New Member
Iam working on Windows Mobile 5.0 that uses C# coding. And on Smartphones virtual keypad comes on the screen whenever there is a textbox to write into it.

I have this textbox that validates only numbers to be entered, but i dont want the character virtual keyboard to arrive on screen, instead by default for this text box, only the numeric keypad to come always.

can you share some small code for textbox.keyPress for this?
Apr 5 '10 #6
tlhintoq
3,525 Recognized Expert Specialist
Ahhh.... See how much details like that help color the landscape?

Have you tried Googling for "Windows mobile numeric keypad" and similar things?

I found this with that Google combination:
http://social.msdn.microsoft.com/For...5-3ea38578abea

Can you access those properties for the TextBox?
Apr 5 '10 #7
gopishk
15 New Member
Thanks for the search,
actually iam looking for the same thing in C#.

The properties of TextBox mentioned are not available in C#.

Can you suggest something similar in C#?
Apr 6 '10 #8
tlhintoq
3,525 Recognized Expert Specialist
I can suggest, to make a custom textbox that does what you need.
Apr 6 '10 #9
gopishk
15 New Member
Do you have any idea about how to implement a custom textbox?
Is this the only way? I thought there would be a simple way to pull a numeric keypad on the screen using C#, similar to the previous link you sent?
Apr 6 '10 #10
tlhintoq
3,525 Recognized Expert Specialist
Nope. Gotta build it yourself.
Inheritence is a really common thing. You can either worry and fret and be afraid of it (so go to cooking school instead) - or you can take a deep breath and give it a try.


Just inherit from TextBox and add some rules/behaviors to match your need. It will just take a little practice and learning, like everything in life. Then you'll get the hang of it and it won't be so scary.

If you were expecting everything you could ever want or need to already be coded for you, so all you had to do was drag and drop from the tool box... someone lied to you.

Do these tutorials from start to end and I think you'll find it something well within you skills.
Events tutorial (including Form to Form which is the same as class to class)
This tutorial for a cash register does exactly that: It makes a virtual numeric keyboard.
Apr 6 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

6
29266
by: Poewood | last post by:
Is there a way to parse the contents of a textbox into a phone number format? Actually I would like to save the input as a number but display it as a phone number in the typical US format (000)...
3
5188
by: Hai Nguyen | last post by:
Hi All I have a textbox want to mask as phone box. How can I do it? Thanks
1
3351
by: womblesjc | last post by:
I have a data bound Details View control in asp.net 2.0 that formats a phone number. The 'Default Mode' for the control is set to Edit. The phone number field is a template field and I can...
10
14280
by: JackM | last post by:
I'm still working on validating the phone numbers that are entered on a form but have come across a problem I don't understand how to fix. I can handle most instances when it's in regular US...
2
3088
by: Melson | last post by:
Hi Does anyone know how to configure the numeric keypad on the keyboard. For example, by pressing button 7, it displays a character. I must also be able to display number 7 whenever I pressed...
3
4095
by: Melson | last post by:
Hi May I know is there a way to change the Numeric keypad into mobile phone keypad? Regards Melson
4
3875
by: Dennieku | last post by:
Hi, I have to develop an on-screen keyboard and on-screen numeric keypad for a touchscreen UI. The hardest thing with this is that it has to be multi-lingual. Has anybody have ideas how to...
20
12932
by: changwl8888 | last post by:
How do i convert an alphabetic phone number to a numeric phone number? Translating alphabetic number: Enter phone number:1-800-COL-LECT 1-800-265-5328
0
1486
by: mcfly1204 | last post by:
I am looking build an onscreen keyboard similar to the onscreen keyboard included in Windows 7, except I only want the numeric keypad portion. I created a C# form with buttons laid out to mimic a...
0
7231
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
7132
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
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.