nbsp; FBookmarks.CurrentRowSelected := True; FSelecting := True; AddAfter := True; end else with FBookmarks do begin AddAfter := Compare(CurrentRow, FSelectionAnchor) <> -Direction; if not AddAfter then CurrentRowSelected := False; end end else ClearSelection; FDatalink.Dataset.MoveBy(Direction); if AddAfter then FBookmarks.CurrentRowSelected := True; finally EndUpdate; end; end;
procedure NextRow(Select: Boolean); begin with FDatalink.Dataset do begin if (State = dsInsert) and not Modified and not FDatalink.FModified then if EOF then Exit else Cancel else DoSelection(Select, 1); if EOF and CanModify and (not ReadOnly) and (dgEditing in Options) then Append; end; end;
procedure PriorRow(Select: Boolean); begin with FDatalink.Dataset do if (State = dsInsert) and not Modified and EOF and not FDatalink.FModified then Cancel else DoSelection(Select, -1); end;
procedure Tab(GoForward: Boolean); var ACol, Original: Integer; begin ACol := IIF(FVertical, Row, Col); Original := ACol; BeginUpdate; { Prevent highlight flicker on tab to next/prior row } try while True do begin if GoForward then Inc(ACol) else Dec(ACol); if ACol >= IIF(FVertical, RowCount, ColCount) then begin NextRow(False); ACol := FIndicatorOffset; end else if ACol < FIndicatorOffset then begin PriorRow(False); ACol := IIF(FVertical, RowCount, ColCount); end; if ACol = Original then Exit; if FVertical then begin if TabStopRow(ACol) then begin MoveCol(ACol); Exit; end; end else if TabStops[ACol] then begin MoveCol(ACol); Exit; end; end; finally EndUpdate; end; end;
function DeletePrompt: Boolean; var Msg: string; begin if (FBookmarks.Count > 1) then Msg := SDeleteMultipleRecordsQuestion else Msg := SDeleteRecordQuestion; Result := not (dgConfirmDelete in Options) or (MessageDlg(Msg, mtConfirmation, mbOKCancel, 0) <> idCancel); end;
const RowMovementKeys = [VK_UP, VK_PRIOR, VK_DOWN, VK_NEXT, VK_HOME, VK_END];
begin KeyDownEvent := OnKeyDown; if Assigned(KeyDownEvent) then KeyDownEvent(Self, Key, Shift); if not FDatalink.Active or not CanGridAcceptKey(Key, Shift) then Exit; with FDatalink.DataSet do if FVertical then if ssCtrl in Shift then begin if (Key in RowMovementKeys) then ClearSelection; case Key of VK_LEFT, VK_PRIOR: MoveBy(-FDatalink.ActiveRecord); VK_RIGHT, VK_NEXT: MoveBy(FDatalink.BufferCount - FDatalink.ActiveRecord - 1); VK_UP: MoveCol(FIndicatorOffset); VK_DOWN: MoveCol(RowCount - 1); VK_HOME: First; VK_END: Last; VK_DELETE: if (not ReadOnly) and not IsEmpty and CanModify and DeletePrompt then if FBookmarks.Count > 0 then FBookmarks.Delete else Delete; end end else case Key of VK_LEFT: PriorRow(True); VK_RIGHT: NextRow(True); VK_UP: if dgRowSelect in Options then PriorRow(False) else MoveCol(Row - 1); VK_DOWN: if dgRowSelect in Options then NextRow(False) else MoveCol(Row + 1); VK_HOME: if (RowCount = FIndicatorOffset+1) or (dgRowSelect in Options) then begin ClearSelection; First; end else MoveCol(FIndicatorOffset); VK_END: if (RowCount = FIndicatorOffset+1) or (dgRowSelect in Options) then begin ClearSelection; Last; end else MoveCol(RowCount - 1); VK_NEXT: begin ClearSelection; MoveBy(VisibleColCount); end; << 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] 下一页 |