真不明白你想干什么,不过你可以这样做,下面是 TCustomDBGrid.MouseUp 虚方法,仔细读一读:
procedure TCustomDBGrid.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
var
Cell: TGridCoord;
SaveState: TGridState;
begin
SaveState := FGridState;
inherited MouseUp(Button, Shift, X, Y);
if (SaveState = gsRowSizing) or (SaveState = gsColSizing) or
((InplaceEditor <> nil) and (InplaceEditor.Visible) and
(PtInRect(InplaceEditor.BoundsRect, Point(X,Y)))) then Exit;
Cell := MouseCoord(X,Y); // 注意本行以及以下代码
if (Button = mbLeft) and (Cell.X >= FIndicatorOffset) and (Cell.Y >= 0) then
if Cell.Y < FTitleOffset then
TitleClick(Columns[RawToDataColumn(Cell.X)]) // 发送 OnTitleClick 事件
else
CellClick(Columns[SelectedIndex]); // 发送 OnCellClick 事件
end;
因为 DblClick 也是虚方法,所以你可以参照上面,override DblClick 方法。
首先添加一个事件:
private
FOnCellDblClick: TDBGridClickEvent;
published
property OnCellDblClick: TDBGridClickEvent read FOnCellDblClick write FOnCellDblClick;
procedure DblClick; override;
begin
// 参照 MouseUp 方法判断点击坐标,有选择性发送 OnCellDblClick 消息
end;
Clear ?
From: BaKuBaKu