Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More about tabbing out of grids
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00368227
Message ID:
00368711
Vues:
17
>>I'm still trying to perfect my code for making grids and their columns work like normal controls regarding tab order. I want users to be able to leave a grid by pressing Tab or Shift-Tab rather than Ctrl-Tab. I made text box classes with code in the Keypress events that do a .SetFocus(othercontrol) when it receives a Tab or Shift-Tab. "othercontrol" is kept in a custom property of the classes. I put these boxes in the first and last column of each of my grids and set the custom properties to the names of the next and previous controls in the tab order.
>>
>>Instead of specifying the name of the next/previous control in the tab order, I would like to set focus automatically to the control that comes after/before the grid in the tab order. I tried calling grid.Valid but it didn't help. I could try looping through all the controls in THISFORM.ControlCount and set focus to the one that has .TabIndex = Grid.TabIndex + 1 or - 1. That seems slow and inefficient for forms with many controls. Also, I'd have to make sure that there was such a control in each form. Is there a better way? In effect, I want something like a "Losefocus" for the grid.
>>
>>Note that in another thread, Dave Frankenbach helped me solve this problem for the case where there are no records in the grid.
>
>Probably you could try to intercept the Shift+Tab in grid and issue KEYBOARD '{CTRL+TAB}' (you may try to do it in Form.KeyPress() )

I put it in the Grid.BeforeRowColChange so that the grid takes care of itself:
LPARAMETERS nColIndex
IF LASTKEY() = 13 OR LASTKEY() = 9 && [Enter] & [Tab]
	IF nColIndex = THIS.ColumnCount
		KEYBOARD "{CTRL+TAB}"
	ENDIF
ENDIF
IF LASTKEY() = 15 && [Shift-Tab]
	IF nColIndex = 1
		KEYBOARD "{CTRL+SHIFT+TAB}"
	ENDIF
ENDIF
To repeat what I said in my other thread, I put this in the grid.When to handle the case where the grid has no records and shouldn't get focus:
IF RECCOUNT(THIS.Recordsource) = 0
	RETURN .F.
ENDIF
If anyone has further suggestions, I'll try them out. I am also willing to entertain criticisms of my Tab-order style or defenses of the default behavior for grids. Otherwise, maybe we should put these two bits of code in the K.B.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform