There has been some recent discussion on how to navigate in a grid i.e. setfocus() where you want it.
I have a grid with line items in it and they can be edited or added to within the grid.
1. In the ACTIVATE() of the form move to the line item required or add a new line item and GO BOTTOM 2. THIS.Invoicegrid.colItemID.Setfocus()
This will have focus set at the bottom item in the itemid column. Fine to this point.
The difficulty is that entering along the row brings me to the Charge column which is ENTERED to accept. The lostfocus() of this cell adds a new blank line item and then setfocus() back to the ItemID. HOWEVER it goes back to the cell of the just completed item and a key_down is needed to get to the correct cell. aha I thought, add KEYBOARD KEY_DOWN to force focus down one line. doesn't work. Due to a bug, I noticed after the bug window was closed that it worked. So the ACTIVATE() is the key? Called ACTIVATE() from the code and nothing happened. The solution!
Add this line to the ACTIVATE() method WAIT WINDOW "" TIMEOUT 1
The wait window removes focus from the form so the activate() fires again and this fires the KEYBOARD command. Works beautifully every time.
Is this the only way to do it or does anyone else have a more elegant solution?
BTW during data entry I force focus to the required cell by having all the other columns enable/disable as needed.
©2001 graeme thomson |