procedure TForm1.PopupMenu2ListSender();
var
addSubItem:TMenuItem;
j:Integer;
begin
QueryPopMenu.Close ;
QueryPopMenu.FetchParams ;
QueryPopMenu.Params.ParamByName('AREA').AsString :=Area;
QueryPopMenu.Open ;
While(PM2Count>0) do
Begin
PopupMenu2.Items[PM2Count-1].Free ; //if from 0 to PM2Count-1 cann't get the correct result,unless take the desc .
Dec(PM2Count);
End;
PM2Count:=0;
While(not QueryPopMenu.Eof)do
Begin
addSubItem:= TMenuItem.Create(Self);
addSubItem.Name := QueryPopMenu.fieldByName('eqpgroup').AsString;
addSubItem.Caption := QueryPopMenu.fieldByName('eqpgroup').AsString;
PopupMenu2.Items.Insert(PM2Count,addSubItem);
addSubItem.OnClick :=PopupMenu2Click;
INC(PM2Count);
QueryPopMenu.Next ;
End;
end;
procedure TForm1.PopupMenu2Click(Sender: TObject);
Begin
Fab := TMenuItem(Sender).Name;
//if take the TMenuItem(Sender).Caption the first letter has a underline , so we cann't get the correct value.
SelectKeyGroup;
End;