当前位置:Gxlcms > 数据库问题 > delphi TDbGrid 右键 PopupMenu 菜单只在有数据的地方弹出

delphi TDbGrid 右键 PopupMenu 菜单只在有数据的地方弹出

时间:2021-07-01 10:21:17 帮助过:32人阅读

www.CodeHighlighter.com/-->procedure TForm1.gridAccountMouseDown(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if (Button = mbright) then begin ShowPopupMenu := False; end; end;

当鼠标弹起的时候在MouseUp事件里判断 ShowPopupMenu 是否为 true

代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->procedure TForm1.gridAccountMouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
begin
  if (Button = mbright) and ShowPopupMenuthen
  begin
    if (gridAccount.SelectedField <> nil) then  //如果有数据
    begin
      //弹出菜单即可
    end;
  end;
  showpop := True;
end;

这样就可以实现在数据区的时候弹出右键菜单了

注:由于俺是新手只能用这种笨方法实现了,如果哪位仁兄有更好的方法希望能告知 thx. 

delphi TDbGrid 右键 PopupMenu 菜单只在有数据的地方弹出

标签:count   mouse   cti   RoCE   col   效果   begin   资料   pre   

人气教程排行