HighTechTalks DotNet Forums  

MaskedTextBox and currency?

Dotnet Framework (WinForms Controls) microsoft.public.dotnet.framework.windowsforms.controls


Discuss MaskedTextBox and currency? in the Dotnet Framework (WinForms Controls) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Bradley Plett
 
Posts: n/a

Default MaskedTextBox and currency? - 12-05-2007 , 02:37 PM






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.

Reply With Quote
  #2  
Old   
Linda Liu[MSFT]
 
Posts: n/a

Default RE: MaskedTextBox and currency? - 12-06-2007 , 03:30 AM






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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #3  
Old   
Linda Liu[MSFT]
 
Posts: n/a

Default RE: MaskedTextBox and currency? - 12-10-2007 , 05:53 AM



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


Reply With Quote
  #4  
Old   
Bradley Plett
 
Posts: n/a

Default Re: MaskedTextBox and currency? - 12-10-2007 , 02:23 PM



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.

On Mon, 10 Dec 2007 10:53:32 GMT, v-lliu (AT) online (DOT) microsoft.com (Linda
Liu[MSFT]) wrote:

Quote:
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

Reply With Quote
  #5  
Old   
Jack Jackson
 
Posts: n/a

Default Re: MaskedTextBox and currency? - 12-10-2007 , 04:02 PM



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.

On Mon, 10 Dec 2007 12:23:53 -0700, Bradley Plett
<plettb (AT) newsgroup (DOT) nospam> wrote:

Quote:
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.

On Mon, 10 Dec 2007 10:53:32 GMT, v-lliu (AT) online (DOT) microsoft.com (Linda
Liu[MSFT]) wrote:

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

Reply With Quote
  #6  
Old   
Linda Liu[MSFT]
 
Posts: n/a

Default Re: MaskedTextBox and currency? - 12-10-2007 , 09:35 PM



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


Reply With Quote
  #7  
Old   
Bradley Plett
 
Posts: n/a

Default Re: MaskedTextBox and currency? - 12-12-2007 , 01:12 PM



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.

On Tue, 11 Dec 2007 02:35:10 GMT, v-lliu (AT) online (DOT) microsoft.com (Linda
Liu[MSFT]) wrote:

Quote:
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

Reply With Quote
  #8  
Old   
Linda Liu[MSFT]
 
Posts: n/a

Default Re: MaskedTextBox and currency? - 12-14-2007 , 05:23 AM



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


Reply With Quote
  #9  
Old   
Mr. Arnold
 
Posts: n/a

Default Re: MaskedTextBox and currency? - 12-15-2007 , 09:06 PM




"Bradley Plett" <plettb (AT) newsgroup (DOT) nospam> wrote

Quote:
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?

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.







Reply With Quote
  #10  
Old   
Bradley Plett
 
Posts: n/a

Default Re: MaskedTextBox and currency? - 12-17-2007 , 12:51 PM



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.

On Sat, 15 Dec 2007 21:06:19 -0500, "Mr. Arnold" <MR.
Arnold (AT) Arnold (DOT) com> wrote:

Quote:
"Bradley Plett" <plettb (AT) newsgroup (DOT) nospam> wrote in message
news:4qudl3to9bhsstlk8h0494169noqlm3nsl (AT) 4ax (DOT) com...
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?


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.





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.