kaborka

I downloaded the DecimalTextBox control sample from

http://download.microsoft.com/download/0/8/7/087e6a47-7306-4a5c-ad97-d1ffd58d712e/DecimalTextBox.msi. I would really like to use this. Unfortunately the code does not work, at least in VS2005SP1. The sample app runs, but when you click the "Commit" button it throws an exception. I get the same exception when I try to place a DecimalTextBox on a form in my own application.

Does anyone have a working version of this control for .NET 2.0

Edit:

I got the demo app to work by entering a valid value into the plain textbox before clicking Commit. However, the control cannot be used in an application via the Designer because the Designer (apparently) attempts to initialize the control's Text property with an empty string, which throws an exception. If I can get it to work I'll post here.



Re: Windows Forms General DecimalTextBox sample

nobugz

Well, it doesn't score a lot of points for being useful. You probably should modify DecimalTextBox.cs and comment out the Debug.Fail() method call in SetFormattedText().





Re: Windows Forms General DecimalTextBox sample

kaborka

I changed it to treat empty string as zero and ignore assignment of bad data. I needed one decimal place with no thousands groups, so I created a custom NumberFormatInfo. I also made it select text on entry so new data replaces the old.

This class needs a LOT of work to make it generally useful, but I may be able to get by with my customized version. I like the way it handles the decimal point. The NumberFormatInfo needs to be exposed, or at least the relevant properties of it, and it needs to handle selected text in a reasonable way. Any volunteers