dxdbgrid的例子中就有这样的代码,其实也不是设成rowselect,是设成可以多select
,然后在判断一下右击在那个位置,不知道dbgrid中能不能判断击了那个位置
hTest in [htColumn, htColumnEdge, htSummaryFooter, htGroupPanel],要不就换dxdbgrid吧
//Mouse Up的时候,判断Mouse Down位置以弹出菜单
procedure TCustomerForm.dxDBGridwater_fountainMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
p: TPoint;
hTest: TdxTreeListHitTest;
begin
if Button = mbRight then
begin
p := dxDBGridwater_fountain.ClientToScreen(Point(X, Y));
hTest := dxDBGridwater_fountain.GetHitTestInfoAt(X, Y);
if not (hTest in [htColumn, htColumnEdge, htSummaryFooter, htGroupPanel]) and
PtInRect(ClientRect, Point(X, Y)) then
begin
dxDBGridwater_fountainSelectedCountChange(nil); // update items
pmDetail.Popup(p.X, p.Y);
end
end;
end;