Hi!
I have an updatable ultragrid. If I am in the last cell of a row I want to put the focus into a button.
This does not work "easily".
If I use the afterCellUpdate Trigger it will not fire if the content of the cell is not modified.
If I use the key-down it will fire for every keystroke I do
If I use afterexiteditmode it will no fire in the last cell of the row (last row).
What is the way to achieve the desired result?
TIA
J. Resperger
Hey Josef,
Had a quick play with this. There is the built in option under the grids DisplayLayout to set the TabNaviagation behaviour. The three options are NextCell,NextControl and NextControlOnLastCell. Unfortunately the last option is the the absolute last editable cell in the Grid. Depending on the behaviour of your grid and what is editable, this may work for you. If not, I played around with overriding the afterCellActivate event and adding code like this (note:you maybe able to clean this up more, its just the code I was playing with to see properties and the like):
----------------------------
define variable ugstate as Infragistics.Win.UltraWinGrid.UltraGridState.
define variable se as System.Enum.
define variable ug as Infragistics.Win.UltraWinGrid.ultraGridLayout.
ugstate = ultraGrid1:CurrentState.
ug = ultraGrid1:DisplayLayout.
if ugstate:HasFlag(Infragistics.Win.UltraWinGrid.UltraGridState:CellLast) then
ug:TabNavigation = Infragistics.Win.UltraWinGrid.TabNavigation:NextControl.
else
ug:TabNavigation = Infragistics.Win.UltraWinGrid.TabNavigation:NextCell.
=====================
So in the IF statement, we test if one of the flags is the CellLast enum. If it is, we change the behavior TabNavigation of the displaylayout of the grid to be go to the next control instead of go to the next cell. Of course, if it isn't the last cell, we change it back to be the next cell instead.
Note: One side effect/bug this doesn't account for is that if your in the last cell and hit Shift-tab, it will still move to another control still and not to the cell before.
Not sure if this helps.
Molly
It's much easier to ride the horse in the direction he is going.
Can you add a button tool with a shortcut (F1, F2, etc.) to an UltraToolBarManager control and accept the default behavior of the UltraGrid? At any point of navigation within the UltrGrid (or anywhere else on the form), when the user clicks your button or presses its shortcut key, capture the event in your code by subscribing to the ToolClick event.
METHOD PRIVATE VOID UltraToolBarsManager1_ToolClick (INPUT sender AS System.Object, INPUT e AS Infragistics.Win.UltraWinToolbars.ToolclickEventArgs):
CASE STRING(CAST(e, ToolClickEventArgs):Tool:Key):
WHEN "ButtonAdd" THEN
DO:
/* something */
END.
WHEN "YourButton" THEN
DO:
/* YourGrid:Activerow <> ?, YourGrid:ActiveCell <> ? */
END.
END CASE.
END METHOD.