2013-12-10 106 views
0

當我右鍵點擊一個DBGrid時,它會打開一個彈出菜單,但是它也會在右擊時選擇(高亮)當前所在的單元格。右鍵點擊TDBGRID delphi2007

有沒有辦法不選擇(hightlight)單擊右鍵單擊並且只有popup菜單打開?

問候 約瑟夫

回答

1

您可能截獲WM_RBUTTONDOWN使用的插入類或自己derivied組件您的DBGrid。
舉例如下:

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;