How to replace the KeyCode System.Windows.Forms.Keys:DECIMAL

Posted by PeterWokke on 10-Sep-2015 04:53

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.

All Replies

Posted by Lieven De Foor on 10-Sep-2015 06:41

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.

Posted by PeterWokke on 10-Sep-2015 07:58

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

Posted by Rob Debbage on 10-Sep-2015 10:26

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. :)

Posted by PeterWokke on 11-Sep-2015 00:02

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.

Posted by Lieven De Foor on 11-Sep-2015 04:04

Don't cast the enum to a string, try this:

IF e:KeyCode:Equals(Keys:Decimal)

THEN...

This thread is closed