Switching from wx-TextCtrl to MaskedNumCtrl

Hi,

I took over a small old project where the predecessor used TextCtrl
fields for pretty much ALL numeric values (inserted them as strings,
read them and converted them to floats .... messy) in the
interface-masks of the program.
In order to make life easier for me and to get to read the calculated
figures more easily, I wanted to change some of the TextCtrls to
masked.NumCtrls
that allow for formatting the figures in regards to decimals, groups/
thousand ..
The problem now is of course that all insertion of the program is
fireing strings causing exceptions ...
Is there a simple (maybe dirty) way to catch what is fired at a
masked.NumCtrl and convert it to the right type prior to insertion?
I am aware that I have to clean up that type-mess rather sooner than
later anyway, but for now I need to evaluate and doublecheck the
figures, i.e. see if the program is calculating corectly - if not I may
start from scratch anyway ...

ThanX,

T

Hi,

I took over a small old project where the predecessor used TextCtrl
fields for pretty much ALL numeric values (inserted them as strings,
read them and converted them to floats .... messy) in the
interface-masks of the program. In order to make life easier for me and
to get to read the calculated figures more easily, I wanted to change
some of the TextCtrls to masked.NumCtrls that allow for formatting the
figures in regards to decimals, groups/ thousand .. The problem now is
of course that all insertion of the program is fireing strings causing
exceptions ... Is there a simple (maybe dirty) way to catch what is
fired at a masked.NumCtrl and convert it to the right type prior to
insertion? I am aware that I have to clean up that type-mess rather
sooner than later anyway, but for now I need to evaluate and doublecheck
the figures, i.e. see if the program is calculating corectly - if not I
may start from scratch anyway ... ThanX, T

Tobias,
Are you binding the validator(s) globally or only on your masked
number controls, if the latter then you shouldn’t be getting the
problem, if the former you need to only bind the validators to those
controls that they apply to.

···

On 18/01/13 09:51, Tobias Weber wrote:


Hi,
I took over a small old project where the predecessor used TextCtrl
fields for pretty much ALL numeric values (inserted them as strings,
read them and converted them to floats .... messy) in the
interface-masks of the program. In order to make life easier for me and
to get to read the calculated figures more easily, I wanted to change
some of the TextCtrls to masked.NumCtrls that allow for formatting the
figures in regards to decimals, groups/ thousand .. The problem now is
of course that all insertion of the program is fireing strings causing
exceptions ... Is there a simple (maybe dirty) way to catch what is
fired at a masked.NumCtrl and convert it to the right type prior to
insertion? I am aware that I have to clean up that type-mess rather
sooner than later anyway, but for now I need to evaluate and doublecheck
the figures, i.e. see if the program is calculating corectly - if not I
may start from scratch anyway ... ThanX, T


Steve Gadget Barnes

Hi Tobias,

Hi,

I took over a small old project where the predecessor used TextCtrl
fields for pretty much ALL numeric values (inserted them as strings,
read them and converted them to floats .... messy) in the
interface-masks of the program. In order to make life easier for me and
to get to read the calculated figures more easily, I wanted to change
some of the TextCtrls to masked.NumCtrls that allow for formatting the
figures in regards to decimals, groups/ thousand .. The problem now is
of course that all insertion of the program is fireing strings causing
exceptions ... Is there a simple (maybe dirty) way to catch what is
fired at a masked.NumCtrl and convert it to the right type prior to
insertion? I am aware that I have to clean up that type-mess rather
sooner than later anyway, but for now I need to evaluate and doublecheck
the figures, i.e. see if the program is calculating corectly - if not I
may start from scratch anyway ... ThanX, T

How is data written to these controls? A validator, just Set/ChangeValue all over the code or ......?

If a validator then you can clean the data in TransferToWindow method, if Set/Change is used maybe have a custom numctrl which has its own Set/Change method which cleans the data and then passed it to the numctrl.Set/Change method.

Have not tried the second suggestion but should work as that is basically what numctrl does.

Werner

···

On 18/01/2013 10:51, Tobias Weber wrote: