效果要求: 点击树形结构不同的行,弹出不一样的下拉菜单
窗体设计:
数据库设计:
实际效果:
核心代码:
procedure TForm1.PopupMenu1Popup(Sender: TObject); var iType: Integer; begin with FDQuery1 do begin if RecordCount = 0 then // 当没有数据时 begin m1.Visible := True; N1.Visible := False; N2.Visible := False; N3.Visible := False; Exit; end; iType := FieldByName('类型').AsInteger; if iType = 0 then // 公司 begin m1.Visible := True; N1.Visible := True; N2.Visible := True; N3.Visible := False; Exit; end; if iType = 1 then // 部门 begin m1.Visible := False; N1.Visible := False; N2.Visible := True; N3.Visible := True; Exit; end; end; end;
标签:begin,菜单,False,delphi,PopupMenu,Visible,iType,end,True From: https://www.cnblogs.com/yoooos/p/16610379.html