Dear all
Is there a good way to make a textbox that receive numeric only?
something that limit the key it respond to
or give sign (like red background or something) if the input is not
numeric
I wonder if validator can be used for that purpose
an example would be very good
btw
is there a datepicker on windows?
Thank you
Regards
Hendra
No reply after 2 days?
thats rare
I would like to believe that some of you guys should
already did this before
and I expect to get some suggestion
of course I can simply add value_change event
and check if corresponding value is numeric or not
but perhaps some of you guys have better ideas?
Set the textfied validator to this:
your_text_field.validator = Wx::TextValidator.new(Wx::FILTER_NUMERIC)
cheers.
bio.
Bad idea
with this validator
I can type 954.564.546…123eee23
that would not be valid number, right?
hendra kusuma wrote:
Bad idea
with this validator
I can type 954.564.546…123eee23
that would not be valid number, right?
I think the validators only work by filtering characters - all of those
characters (including e, for scientific notation) are potentially part
of a valid number. But it won’t test if the whole string is a valid
number.
If you need that level of sophisticated filtering, you could add an
event handler to the textctrl which checks in Ruby that the string can
be validly converted to a number. Something like (untested)
evt_text(my_textctrl) do | e |
begin
num = Float(my_textctrl.value)
rescue ArgumentError
puts ‘sorry that’s a valid string’
end
end
a
On Tue, Dec 15, 2009 at 3:56 AM, Alex F. [email protected] wrote:
end
Yes, this is exactly what I think at first
I just want to know if there is a build in library for that purpose
Thanks anyway