I read through KB Article: KB02028 which shows a Sub to make the Enter key act like the Tab key when hit while in the UltraGrid. However it does not explain how to call it or when to call. Does anyone have any advice as how to implement it?
Thanks
Gary
Hi Gary,
The code in this sample is modifying the grid's KeyActionMapping collection. So you can call this code from anywhere you want. It just needs to be called once, up front, to modify the grid for the lifetime of the control.
So the Form_Load event it a good place to call this method and you would call it once for each UltraGrid on the form.
Mike,
Thanks, gave it a try and it worked like a charm. However I called it from the Grid's InitializeLayout event putting it with other initializing stuff.
InitializeLayout will probably work for most application, but you have to be careful, because InitializeLayout may get called more than once.
It gets called any time you set the grid's DataSource/DataMember and it may also fire when you load a layout or get a Reset notification from the data source - although I'm not 100% sure about those two cases.
So if the event gets called a second time, you might end up adding in the mappings twice and the Enter key will start tabbing two cells instead of one.
Hi,
Sure, you can make Enter do whatever you want. Here's a KB article that will get you started:
HOWTO:UltraWinGrid Cursor Movement like Excel
You just have to switch NextCellByTab with PrevCellByTab and vice versa.
Hello Mike,
Is it possible to Map the enter Key to move left instead of moving right for RTL support?
Thanks,
ellswrth said:Any idea where I might look to track down the source of this issue?
I assume you are using code in the KeyDown or KeyPress event of the grid to acheive this. Can you post the code you are using?
Have you tried putting a breakpoint in that code to see if it's doing what it should be doing?
Are you handling other events of the grid, such as BeforePerformAction?
Have you modified the grid's KeyActionMappings?
ellswrth said:Is it potentially related to having configured shortcuts on menu items that map to Ctrl-Tab?
It's possible, but I'm not sure. It seems like you are saying that this only happens in some cells and not others. If it happens in cells that use masking (like DateTime cells) and does not happen in cells with plain text, then that would be an indication that something else may be interfering with the keystrokes because when you edit a plain text cell in the grid, the grid display a child control (A textBox) over the cell and it does not do this with masked cells. So this could be an issue with which control currently has focus.
This should be very easy to test, though. Simply change your shortcuts so they don't use Tab or Shift+Tab (or Enter) and see if that fixes it.
Sorry to resurrect an old one but I'm getting weird results.
I applied this to an existing grid - cell(0) and cell(1) are a date datatype/date time editor. When I add a row, I seed those two cells with a datetime value and put the user in cell(1) in edit mode with the text selected (so they just start typing to replace it).
When they press the enter key to leave the cell, instead of moving to cell(2) as the tab key would do, the Enter key moves DOWN a cell, adding a new row but leaving fields empty in the previous row.
Any idea where I might look to track down the source of this issue?
Is it potentially related to having configured shortcuts on menu items that map to Ctrl-Tab?
Thank for the pointer. I will keep that in mind when working on this form.