DBGrid - enter para pular entre campos |
Top Previous Next |
|
// Fazer enter pular campos no Grid. // GridKeyDown
if (Key = Vk_Return) and (Shift = []) then if Grid.SelectedIndex = (Grid.FieldCount - 1) then if Table.CampoVazio('nome') then Grid.SelectedIndex := 0 else if Table.EOF then Table.Append else begin Grid.SelectedIndex := 0; Table.Next; end else Grid.SelectedIndex := Grid.SelectedIndex + 1;
---------- another way ------------
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin if DBGrid1.Columns.Grid.SelectedIndex < DBGrid1.Columns.Count - 1 then DBGrid1.Columns[DBGrid1.Columns.grid.SelectedIndex + 1].Field.FocusControl else begin Table1.Next; DBGrid1.Columns[0].field.FocusControl; end; end; end;
. |