Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / December 2007

Tip: Looking for answers? Try searching our database.

MaskedTextBox and currency?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bradley Plett - 05 Dec 2007 19:37 GMT
Either I don't know how to use it particularly well (entirely
possible), or the MaskedTextBox included with VS2005 (and VS2008)
really sucks!!!  All I need is a simple control to allow me to enter
decimal or currency values.  I would prefer behavior that looks a lot
more like a standard text box, rather than showing the mask or
dictating the number of digits.  I'd like it to be aware of the
decimal functionality and handle it properly (e.g. I want to be able
to type 1.23 regardlesss of how long the entry can be).

Is there a good open-source alternative out there?  What are people
using?  I found nothing on SourceForge.  I found a few on CodeProject,
but those tend not to be maintained over time, and I don't think I've
found the ideal one yet.

This seems like such a simple and fundamental control, but I haven't
had much luck finding a good one.  I thought about writing it myself,
but 1) I simply don't have the time, and 2) I can't imagine there
isn't already a good one out there!

Any thoughts or opinions?

Thanks!
Brad.
Linda Liu[MSFT] - 06 Dec 2007 08:30 GMT
Hi Brad,

I understand your concern.

The MaskedTextBox class is an enhanced TextBox control that supports a
declarative syntax for accepting or rejecting user input. It has some
restrictions, e.g. the user could only input specified length of text and
in specified mask into a MaskedTextBox. So the MaskedTextBox is not
appropriate to your scenario.

I suggest that you use a TextBox control instead and validate wether the
text the user inputs in the TextBox is valid or not using a proper regular
expression.

For a complete sample on how to do this, please refer to the following
technical article:
'Adding Regular Expression Validation'
http://msdn2.microsoft.com/en-us/library/ms996428.aspx

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Linda Liu[MSFT] - 10 Dec 2007 10:53 GMT
Hi Brad,

How about the problem now?

If you have any question, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support
Bradley Plett - 10 Dec 2007 19:23 GMT
I was still hoping for some community feedback (e.g. what other people
are using).  I assume, since I'm guessing this is such a common
problem, that there must be some good alternatives out there rather
than each person writing his/her own version.

Though I'm disappointed that MS doesn't have something better for
this, it's not something I expect MS to fix at this point.

Brad.

>Hi Brad,
>
[quoted text clipped - 7 lines]
>Linda Liu
>Microsoft Online Community Support
Jack Jackson - 10 Dec 2007 21:02 GMT
After trying MaskedTextbox and finding it very inadequate for numbers,
I wrote my own subclass of Textbox to allow me to limit the number of
digits before and after the decimal point.  Since it wasn't hard to do
I didn't bother trying to find an existing non-MS solution, so I don't
know if there is anything available or not.

>I was still hoping for some community feedback (e.g. what other people
>are using).  I assume, since I'm guessing this is such a common
[quoted text clipped - 17 lines]
>>Linda Liu
>>Microsoft Online Community Support
Linda Liu[MSFT] - 11 Dec 2007 02:35 GMT
Hi Brad,

Thank you for your reply!

You may go to the Microsoft Connect web site to make a suggestion on this
issue:
http://connect.microsoft.com/VisualStudio/Feedback

Thank you for your support and contribution to Microsoft!

Sincerely,
Linda Liu
Microsoft Online Community Support
Bradley Plett - 12 Dec 2007 18:12 GMT
There are already at least two feedback items on this topic.  They
were raised when VS2005 was in beta, and it appears they simply get
dismissed.  I guess there just isn't enough community support for this
kind of a thing.  :-(

Brad.

>Hi Brad,
>
[quoted text clipped - 9 lines]
>Linda Liu
>Microsoft Online Community Support
Linda Liu[MSFT] - 14 Dec 2007 10:23 GMT
Hi Brad,

Well, I will make a suggestion for you on this issue in our internal
discussion group.

Hope that would draw our product team's attention.

Sincerely,
Linda Liu
Microsoft Online Community Support
Linda Liu[MSFT] - 20 Dec 2007 09:49 GMT
Hi Brad,

Sorry for my delayed reply!

Our product team replied as follows:

We wrote a full-featured sample DecimalTextBox control that can be
installed from here:

http://download.microsoft.com/download/0/8/7/087e6a47-7306-4a5c-ad97-d1ffd58
d712e/DecimalTextBox.msi

Hope this is what you want.

Sincerely,
Linda Liu
Microsoft Online Community Support
Bradley Plett - 21 Dec 2007 01:26 GMT
Thanks a lot!  I think I'll use that for now, but I still think it's
something MS should include with the product.

Brad.

>Hi Brad,
>
[quoted text clipped - 13 lines]
>Linda Liu
>Microsoft Online Community Support
Mr. Arnold - 16 Dec 2007 02:06 GMT
> Either I don't know how to use it particularly well (entirely
> possible), or the MaskedTextBox included with VS2005 (and VS2008)
[quoted text clipped - 16 lines]
>
> Any thoughts or opinions?

Why don't you just use a function that returns true or false to check if
numbers and the period are being entered, which can be done on the Textbox
Keypress event.

e.handle = cknumberorperiod(e.key);   //or something like that.

You have to account for the backspace key in the function.
Bradley Plett - 17 Dec 2007 17:51 GMT
The fact that this is reasonably easy to do misses the point.  Decimal
and currency entry is so common, I can't believe there is no control
included for it!

Brad.

>> Either I don't know how to use it particularly well (entirely
>> possible), or the MaskedTextBox included with VS2005 (and VS2008)
[quoted text clipped - 24 lines]
>
>You have to account for the backspace key in the function.
Mr. Arnold - 18 Dec 2007 04:23 GMT
> The fact that this is reasonably easy to do misses the point.  Decimal
> and currency entry is so common, I can't believe there is no control
> included for it!

Why beat yourself up about it? You should find an alternate path and let the
good times roll. :)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.