Sven's Blog

MemoryStream ms = new MemoryStream(MyBrain); // Management and technology considerations

Subscriptions

<March 2010>
SuMoTuWeThFrSa
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

News

Welcome to my spot on the 'Net. I am the Principal Consultant at Adduxis, a management and IT consulting firm. This blog will provide you with some (hopefully) useful information and links to tidbits found on the Internet.

Navigation

Post Categories

Microsoft Bloggers

A Currency MaskedTextBox for .NET 2.0

At a customer's site, an application needed to format and accept formatted input for currencies. They had already made several attempts at getting the .NET 2.0 WinForms MaskedTextBox to behave the way they wanted, without success.

A quick search reveals that they were not the only ones struggling with this issue. However, Irena Kennedy [1] had posted some sample code that would make the MaskedTextBox behave more appropriately. While the sample provides an excellent overview of how to handle currency values, two features were lacking:

  • Support for the currency group separator (the , in the US English culture)
  • Support for different cultures (important, considering the fact that the default MaskedTextBox allows you to specify a culture)

The download below [2] is a zip file containing a sample implementation for both of the above features. The code is based on Irena's code. Feel free to download this sample and use it in your applications. However, I provide no warranty whatsoever that this CurrencyMaskedTextBox will suit your needs. If you make any modifications, please continue to include my name and Irena's name.

[1]: http://blogs.msdn.com/irenak/archive/2006/03/21/556434.aspx

[2]: http://www.adduxis.com/downloads/CurrencyMaskedTextBox/CurrencyMaskedTextBox01.zip

posted on Wednesday, June 21, 2006 3:09 PM by SvenAelterman

Powered by Community Server, by Telligent Systems