Right clicking on TDBGRID delphi2007

384 views Asked by At

When I right-click on a DBGrid it opens a popupmenu, but it also selects (hightlights) the cell I am currently over when right-clicking.

Is there a way to not select(hightlight) the cell I am over when right-clicking and only have the popupmenu open?

Best regards Josef

1

There are 1 answers

0
bummi On

You might intercept WM_RButtonDown for your DBGrid using an interposer class or an own derivied component.
An example could look like:

type
  TDBGrid=Class(VDBGrids.TDBGrid)
    Procedure WMRButtonDown(var Msg:TMessage);Message  WM_RButtonDown;
  End;

  TForm3 = class(TForm)
    ........

implementation

{$R *.dfm}

{ TDBGrid }

procedure TDBGrid.WMRButtonDown(var Msg: TMessage);
begin
   if Tag = 123 then  // abuse the tag or implement an own property to handle only wished grid
      Msg.Result := 0
   else inherited;
end;