-
Jan 24th, 2012, 12:05 PM
#1
Thread Starter
Hyperactive Member
-
Jan 24th, 2012, 12:41 PM
#2
Re: *NEW* SmartTextBox
Looks usfull thanks for shareing. ps can I ask how do you color the VB.NET in the posts
-
Jan 24th, 2012, 12:45 PM
#3
Re: *NEW* SmartTextBox
Originally Posted by BenJones
ps can I ask how do you color the VB.NET in the posts
Just put your code in [HIGHLIGHT="vbnet"]your code here[/HIGHLIGHT] tags
-
Jan 24th, 2012, 02:38 PM
#4
Thread Starter
Hyperactive Member
Re: *NEW* SmartTextBox
Originally Posted by BenJones
Looks usfull thanks for shareing. ps can I ask how do you color the VB.NET in the posts
Yup just as he said, Click the 'VBCode" then whent he input message pops up type "vbnet".
Also thanks! I feel this is extremely useful. I'm truly surprised Microsoft didn't have anything like this with their own. Especially the input restrictions. Not every textbox in every context takes every input value. Makes things much easier to simply restrict them from the start so you don't have to worry about it later.
I just updated to some more restrictions. More specifics like currency and my numeric now lets some specific digits through, whereas my new strictly numeric type only allows numerical values.
EDIT: I'd like to note my title is a little misleading, it is not completely my own. But rather implemented and customized to expand functionality.
Last edited by DavesChillaxin; Jan 24th, 2012 at 02:54 PM.
-
Jan 24th, 2012, 12:59 PM
#5
Re: *NEW* SmartTextBox
Thanks CVMichael I try it out on one of my next posts.
-
Jan 24th, 2012, 11:20 PM
#6
Re: *NEW* SmartTextBox
Though this looks like a great start to an all-in-one textbox control, I do see a few things with it. If you're going to be handling currency you should probably make use of the globalization to determine if the input is valid for currency, rather than hard code $'s, or pound sign (£ or ₤) and so on.
DavesChillaxin, one of the reasons a control like this isn't natively in the framework is probably because MS developed separate controls for these types of things, really the only thing that your control does that none of the current MS ones do is the watermark. For numeric only input there's the NumericUpDown control, for standard text box there's the TextBox & for anything that needs to be specially formatted (like currency or a phone number, or SSN, etc) there's the MaskedTextBox where you set the input mask to what you need. Separate controls for specific needs instead of 1 control for most (or all) needs.
-
Jan 26th, 2012, 01:39 PM
#7
Thread Starter
Hyperactive Member
Re: *NEW* SmartTextBox
Originally Posted by JuggaloBrotha
Though this looks like a great start to an all-in-one textbox control, I do see a few things with it. If you're going to be handling currency you should probably make use of the globalization to determine if the input is valid for currency, rather than hard code $'s, or pound sign (£ or ₤) and so on.
I had already considered this, but for my application I'm sticking with whats local. The program I initially made this for has no intentions of ever handling any currency types other than USD or any type that uses the $ sign. Small business' don't handle more than one type of currency at a time so to have that option would be a flop. Rather I could have another property set aside for when currency has been selected, you can then input the currency sign of your requirements(by default $ would be used)
DavesChillaxin, one of the reasons a control like this isn't natively in the framework is probably because MS developed separate controls for these types of things, really the only thing that your control does that none of the current MS ones do is the watermark. For numeric only input there's the NumericUpDown control, for standard text box there's the TextBox & for anything that needs to be specially formatted (like currency or a phone number, or SSN, etc) there's the MaskedTextBox where you set the input mask to what you need. Separate controls for specific needs instead of 1 control for most (or all) needs.
I feel if a company has passwords, such as PINS - then a numericupdown would definitely not be the control to use. So still I would have to create a textbox, and then code under it's respectable events to restrict all characters but numbers. This is a lot more work to do when all I would have to do is add my modified textbox and select it's input type to numeric only. Same for currency and phone input fields. I have multiples of them, and I don't want to have to code them all. My application is a business management and inventory system. I have multiple forms with specific input fields. I'm not about to code every single one of those textboxes when I can add mine, and select a property to specify it's input types.
Also the decimal point. I have my modified textbox restricting only one to be passed when the input type involve numerics. To have more than one would always cause problems unless dealing with IPs-which I feel like adding as a specific input type.
So really I'm just controlling the input of characters. I'm not formatting the text to any specific format types. Just restricting specific characters according to what the developers use for that textbox might be. Solves the problem at the source.
Last edited by DavesChillaxin; Jan 26th, 2012 at 01:43 PM.
-
Jan 26th, 2012, 03:00 PM
#8
Re: *NEW* SmartTextBox
Originally Posted by DavesChillaxin
I had already considered this, but for my application I'm sticking with whats local. The program I initially made this for has no intentions of ever handling any currency types other than USD or any type that uses the $ sign. Small business' don't handle more than one type of currency at a time so to have that option would be a flop. Rather I could have another property set aside for when currency has been selected, you can then input the currency sign of your requirements(by default $ would be used)
Something like that could always be put in later if the situation where to arise. I could see where even a small company could deal with multiple currencies in Europe , but here in the Americas I agree with you.
Though come to think of it, I have had a situation where I wanted numeric only input (a measurement in inches) and I wanted to show the inch symbol (") on the right of the number, I ended up making my own NumericUpDown control that inherited the one in the framework and had it display the " after the number but still functioned exactly like a NUD (the Value property still returned the numeric value as a Decimal), so the Text property would show 4.3" but the Value property returns 4.3D, You could do something similar for currency and have it get the symbol to show from the language globalization.
Just something to think about.
Originally Posted by DavesChillaxin
I feel if a company has passwords, such as PINS - then a numericupdown would definitely not be the control to use. So still I would have to create a textbox, and then code under it's respectable events to restrict all characters but numbers. This is a lot more work to do when all I would have to do is add my modified textbox and select it's input type to numeric only. Same for currency and phone input fields. I have multiples of them, and I don't want to have to code them all. My application is a business management and inventory system. I have multiple forms with specific input fields. I'm not about to code every single one of those textboxes when I can add mine, and select a property to specify it's input types.
For entering a PIN, I wouldn't use a NumericUpDown either and because of all the work involved in maintaining the code to restrict a TextBox to only allowing numeric only input and enforcing a number of digits the PIN is (4 digit PIN, 6 digit PIN, etc) I would use a MaskedTextBox control and set it's Mask property to "0000" for a 4 digit PIN or "000000" if it's a 6 digit PIN, the "0" means that character is numeric only not counting a decimal and is required so it can't be blank either. 4 of them together means all 4 of them are required in the same manor.
Here's more the Mask property: http://msdn.microsoft.com/en-us/libr...tbox.mask.aspx
Anything that requires a format like this is where I would use a MTB.
Originally Posted by DavesChillaxin
Also the decimal point. I have my modified textbox restricting only one to be passed when the input type involve numerics. To have more than one would always cause problems unless dealing with IPs-which I feel like adding as a specific input type.
Same thing can be done with an MTB and the Mask would be something like "990.990.990.990"
Originally Posted by DavesChillaxin
So really I'm just controlling the input of characters. I'm not formatting the text to any specific format types. Just restricting specific characters according to what the developers use for that textbox might be. Solves the problem at the source.
Like I said, this control you've got started here could easily become an all-in-one control if that's what you're really wanting, but personally I've never felt the need to want to maintain a control like this because situations are going endlessly arise where you're constantly having to go back and revise it because of some requirement you've got with it or maybe even because something in Windows or in the Framework has changed and now your control needs to be updated to accommodate it. I tend to have different controls for the different purposes and I try to use what's in the FW as much as possible so that MS keeps it up to date, not me. I have enough to maintain in my programs as it is. Just saying.
-
Jan 28th, 2012, 09:39 AM
#9
Thread Starter
Hyperactive Member
Re: *NEW* SmartTextBox
Oh well, everyone's a critic online.
-
Jan 28th, 2012, 10:27 AM
#10
Thread Starter
Hyperactive Member
Re: *NEW* SmartTextBox
EDIT: Actually I figured one out through some research. Check the original post for the update.
Does anyone know a better watermark method than the one used here? I'm not sure why but by changing the actual text through certain events can get tricky and seems to have it's hiccups. My first attempt which seemed bullet proof was to selectively overrides the paint event, but I soon realized this is nearly impossible when inheriting the textbox. My researched taught me the textbox draws... differently. So that idea was scratched quickly.
Also I'd prefer not to change the text for any value returning purposes. I don't want to by accident return the watermark when calling for the Text value. Just seems like a bad idea anyway, but for now it was my only option.
Thanks in advanced!
Last edited by DavesChillaxin; Jan 28th, 2012 at 11:06 AM.
-
Aug 2nd, 2012, 01:30 PM
#11
Re: *NEW* SmartTextBox
Originally Posted by DavesChillaxin
Does anyone know a better watermark method than the one used here?
There are a couple of different ways that I gave here: http://www.vbforums.com/showthread.p...-box-watermark
This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.
The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.
-
Aug 4th, 2012, 08:02 PM
#12
Member
Re: *NEW* SmartTextBox
is this works with multiline textbox
-
Aug 12th, 2012, 03:00 PM
#13
Re: *NEW* SmartTextBox
Originally Posted by rojaldearintok
is this works with multiline textbox
Not if you use EM_SETCUEBANNER, when in doubt look it up on MSDN...
EM_SETCUEBANNER message
Remarks
An edit control that is used to begin a search may display "Enter search here" in gray text as a textual cue. When the user clicks the text, the text goes away and the user can type.
You cannot set a cue banner on a multiline edit control or on a rich edit control.
Minimum supported client: Windows XP
Minimum supported server: Windows Server 2003
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|