On a UltraGrid I have activated the KeyDown event.
@VisualDesigner.
method private void ultraGridAvailability_KeyDown( input sender as System.Object, input e as System.Windows.Forms.KeyEventArgs ):
/* System.Windows.Forms.Keys:DECIMAL:ToString() = the decimal key on the numeric part of the keybord */
if e:KEYCODE:ToString() = System.Windows.Forms.Keys:DECIMAL:ToString() then do:
/* How to replace this e:KEYCODE with the session:numeric-decimal-point value */
end.
So you want to simulate how way Excel works?
Have a look here: stackoverflow.com/.../replacing-the-decimal-point-key-from-numpad-with-correct-decimal-separator-in
By the way, you shouldn't be comparing ToString() of enums, use Progress.Util.EnumHelper:AreEqual() instead.
Hello Lieven,
Thanks for your replay. I have read the link.
Most solutions are not in the KeyDown event on this link.
None of them is Progress.
Have not much experience on the Progress.Util.EnumHelper:AreEqual()
If you have an example of this I can use to replace:
if e:KEYCODE:ToString() = System.Windows.Forms.Keys:DECIMAL:ToString() then do:
I would be pleased.
e:KEYCODE has only a get option.
I cannot change its value like
e:KEYCODE = session:numeric-decimal-point.
Basically I should replace if the active cell is a decimal.
in other type of cells it does not need replacements.
Regards,
Peter
Hi Peter,
You should be able to use something like this in your KeyDown event:
IF e:KEYCODE:ToString() = "Decimal" THEN DO:
e:SuppressKeyPress = TRUE.
System.Windows.Forms.SendKeys:Send(SESSION:NUMERIC-DECIMAL-POINT).
END.
It stops the original keypress and send another in its place.
Modify/improve as needed. :)
Hi Rob,
Thank you kindly for your input. I have implemented this in a case block.
Testing the ultraGridAvailability:ActiveCell in it as well.
Works fine with this.
Regards, Peter.
when System.Windows.Forms.Keys:DECIMAL:ToString() then do:
oldIndex = ultraGridAvailability:ActiveCell.
if oldIndex = ? then return.
e:SuppressKeyPress = true.
System.Windows.Forms.SendKeys:Send(session:numeric-decimal-point).
end.
Don't cast the enum to a string, try this:
IF e:KeyCode:Equals(Keys:Decimal)
THEN...