> if(e.KeyChar == '.')
> {
[quoted text clipped - 7 lines]
> You don't really need to use the box variable, it just makes it more
> general purpose.
Thank you very much! That's it! :)
>> Hi!
>>
[quoted text clipped - 25 lines]
> e.Handled = true;
> }
This doesn't properly handle the case when there is text selected already.
Try constructing a new KeyPressEventArgs with a comma, and pass that to
base.OnKeyPress.... oh wait, you're using an event, not an override. Call
SendMessage(box.Handle, WM_CHAR, ...) to get the proper default handling of
the key.
> You don't really need to use the box variable, it just makes it more
> general purpose.
Frank Adam - 08 Feb 2008 06:05 GMT
>This doesn't properly handle the case when there is text selected already.
>
>Try constructing a new KeyPressEventArgs with a comma, and pass that to
>base.OnKeyPress.... oh wait, you're using an event, not an override. Call
>SendMessage(box.Handle, WM_CHAR, ...) to get the proper default handling of
>the key.
In '08, a simple "if (e.KeyChar == '.') e.KeyChar = ',';" certainly
works, though obviously won't handle pastes.
To add to the confusion and as long as complete novels are not
entered, one could just use TextChanged. For the average text fields
used in my apps, i can't outtype this thing below. Maybe i'm too slow.
;)
private void tb_Changed(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
int tbStart = tb.SelectionStart;
tb.Text = tb.Text.Replace('.', ',');
tb.SelectionStart = tbStart;
}
Then again, why not just do that on Validate.. the only time i found
swapping keys on a user is for prank purposes. :)

Signature
Regards, Frank
Ben Voigt [C++ MVP] - 11 Feb 2008 14:51 GMT
>> This doesn't properly handle the case when there is text selected
>> already.
[quoted text clipped - 22 lines]
> Then again, why not just do that on Validate.. the only time i found
> swapping keys on a user is for prank purposes. :)
The specific case of dot/comma suggests international entry of numeric
values.
christery@gmail.com - 12 Feb 2008 01:06 GMT
> The specific case of dot/comma suggests international entry of numeric
> values.- Dölj citerad text -
Hmm, 123,312.12 uses both... wich is wich.. is there a INTERnational
standard for the case? and if not why? yes u can put it in win doze
that it will read (or anyway write it that way) but is that
implemented... Im running circles around swedish chars... really nice
when going dipped in 7 bit somewhere... it sort of get like "Wdlcome"
instead of "Welcome"...
//CY
Frank Adam - 12 Feb 2008 02:04 GMT
>> The specific case of dot/comma suggests international entry of numeric
>> values.- Dölj citerad text -
>
>Hmm, 123,312.12 uses both... wich is wich.. is there a INTERnational
Indeed. Hence my notion that this should rather be done on Validate or
perhaps on the enter key and not drive the user nuts with replacing
his or her keystrokes. I know that if i typed a dot and it turned into
a comma, i'd be staggering up the keyboard for the backspace and
blaming the bottle for mishitting the keys.

Signature
Regards, Frank