restricting entry in a text box
-
hi friends, can i control the text to be typed in a textbox? i.e. i want only hex data (A-F, 0-9)to be typed by the user, he should not be able to type any another data. i tried to use the keydown property also, can i delete a perticular charater from the textbox? i want the user to enter the MAC address in the form 3A:26:b9:12:34 in the text box. but when i process the text in the textbox, i want to exclude the ':'. how can i do it?
-
hi friends, can i control the text to be typed in a textbox? i.e. i want only hex data (A-F, 0-9)to be typed by the user, he should not be able to type any another data. i tried to use the keydown property also, can i delete a perticular charater from the textbox? i want the user to enter the MAC address in the form 3A:26:b9:12:34 in the text box. but when i process the text in the textbox, i want to exclude the ':'. how can i do it?
1. There should be an event when the textbox-contents changes. -> get the string out of the textbox, check for illegal characters, delete them, put text back into the textbox. 2. Like 1., you can get and set the text from the textbox with the "Text" property. look on msdn for more info on the textbox members and properties. good luck. No hurries, no worries.
-
hi friends, can i control the text to be typed in a textbox? i.e. i want only hex data (A-F, 0-9)to be typed by the user, he should not be able to type any another data. i tried to use the keydown property also, can i delete a perticular charater from the textbox? i want the user to enter the MAC address in the form 3A:26:b9:12:34 in the text box. but when i process the text in the textbox, i want to exclude the ':'. how can i do it?
- Use the
KeyPress
event, if the character is invalid set thee.Handled
property to false, and then it won't appear in the textbox. 2) UsemacAddr = textbox1.Text.ToString().Replace(":", "")
Note this is from the top of my head and the syntax may be slightly off:) Hope this helps
- Use the
-
hi friends, can i control the text to be typed in a textbox? i.e. i want only hex data (A-F, 0-9)to be typed by the user, he should not be able to type any another data. i tried to use the keydown property also, can i delete a perticular charater from the textbox? i want the user to enter the MAC address in the form 3A:26:b9:12:34 in the text box. but when i process the text in the textbox, i want to exclude the ':'. how can i do it?
Have a look at this article http://www.codeproject.com/useritems/shellcontrol.asp[^]. It demonstrates a few techniques to filter keystrokes. Regards Senthil _____________________________ My Blog | My Articles | WinMacro