TcxCustomGridTableController.FocusNextItem(Integer,Boolean,Boolean,Boolean,Boolean,Boolean) Method
Moves focus to the nearest available data item that follows or precedes the specified data item.
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
AFocused |
Integer | Specifies the visible index of the focusable data item used as the start position of the current focus movement operation. The function moves focus to the next or previous available data item depending on the |
AGo |
Boolean | Specifies the direction of focus movement:
|
AGo |
Boolean |
|
AGo |
Boolean | Specifies if focus can navigate between records if
|
AFollow |
Boolean | Specifies if the function iterates through data items according to their positions in the grid View layout:
|
ANeed |
Boolean | Optional. Specifies if the function clears the current selection and selects the record that contains the focused data item:
|
#Returns
Type | Description |
---|---|
Boolean |
The |
#Remarks
You can set an individual data item’s Options.Focusing property to False
to prevent users from moving focus to the data item. Such items cannot accept focus, and all keyboard navigation operations skip these items.
Call the FocusNextItem
function to move focus to the available data item closest to the required position (visible data item index) passed as the AFocusedItemIndex
parameter.
#Code Example: Press Enter to Navigate Between Columns
The code example in this section allows users to press Enter or Shift+Enter in the active in-place cell editor to confirm pending changes and navigate to the next or previous cell in the same record, respectively. You can use the AItem
parameter to identify the target column and limit this navigation technique to certain columns in your application.
procedure TMyForm.cxGrid1TableView1EditKeyDown(Sender: TcxCustomGridTableView;
AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit; var Key: Word; Shift: TShiftState);
begin
if Key = VK_RETURN then // Checks if the Enter key is pressed
begin
if Shift = [ssShift] then // Checks if only the Shift modifier key is pressed
(Sender as TcxGridTableView).Controller.FocusNextItem(AItem.Index, False, False, False, True)
else
(Sender as TcxGridTableView).Controller.FocusNextItem(AItem.Index, True, False, False, True);
end;
end;
Tip
Alternatively, you can set the OptionsTrue
.