Extended and Date Winform Textboxes
VB.NET User Controls: Extended and Date Textboxes
"This article offers two user controls that are alternatives to the standard VB.NET TextBox
.
DateTextbox
... an aggregate of a standardTextBox
and a calendar button.ExtendedTextbox
... adds six properties to the standardTextBox
for controlling textbox behavior.
DateTextbox
The
DateTextbox
is an aggregate of a standard TextBox
and a Button
. When the button is clicked, a calendar is displayed.... ExtendedTextbox
The
ExtendedTextbox
can be used in any VB.NET project as a replacement for the standard TextBox
. This user control adds several extension properties that can be used to determine how the textbox will respond to keystrokes, and what happens when the textbox gets and loses the focus. _HighlightText Boolean
When true, any pre-existing text is highlighted when the textbox receives the focus. The user can replace the pre-existing text by just starting to type. When false, text is not highlighted and the insertion cursor is placed at the end of the text.
_TrimSpaces Boolean
When true, any leading and trailing spaces are removed from the text when the textbox loses the focus.
_Keystrokes Multiple options
All ... Accepts all keystrokes the same as the standard TextBox.
LettersOnly ... Accepts upper and lower case letters (a-z, A-Z) and space (to accept only lower or upper case letters, set the standard CharacterCasing property).
NumbersOnly ... Accepts numbers (0-9) plus allowed number related special characters (minus sign, decimal point, thousands separator).
NoSpecialChar ... Accepts upper and lower case letters (a-z, A-Z), numbers (0-9), and space.
PhoneChar ... Accepts numbers (0-9) plus (), -, and space.
_MinusSign Boolean
When true, accepts a minus sign (the minus sign character set in the OS region settings) in the first character position of the textbox. In effect only when the _Keystrokes property is set to NumbersOnly.
_DecimalPoint Boolean
When true, accepts one decimal point (the decimal point character set in the OS region settings). In effect only when the _Keystrokes property is set to NumbersOnly.
_ThousandsSeparator Boolean
When true, accepts any number of thousands separators (the digit grouping character set in the OS region settings). In effect only when the _Keystrokes property is set to NumbersOnly.
..."
I needed something just like this the other day. I needed a simple textbox limited to numbers only and that highlighted on focus. Sure it’s easy enough to code that, but I’m pretty lazy and hate rewriting the same code over and over (even to snipping over and over... ). An extender is a good solution for this problem.
I ended up using a third party control that I already owned (Infragistics UltraNumericEditor). But I also hate using a 10 pound sledge to hammer in drywall nails (I’m just never happy am I?).
This is a VB 7.1 project, but looks easily upgradable to VB8...
No comments:
Post a Comment