Sven's Blog

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

Subscriptions

<November 2008>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

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

Wednesday, June 21, 2006 - Posts

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 Wednesday, June 21, 2006 3:09 PM by SvenAelterman with 0 Comments

Powered by Community Server, by Telligent Systems