procedure TForm1.Pop1_1Click(Sender: TObject);
var a:string;
begin
a:=PopMenu1.PopupComponent.Name;
if a = 'ListView1' then begin
.......
exit;
end;
if a = 'ListView2' then begin
.......
exit;
end;
if a = 'ListView3' then begin
.......
exit;
end;
if a = 'ListView4' then begin
.......
exit;
end;
我现在的有没办法共用啊
var a:string;
begin
a:=PopMenu1.PopupComponent.Name;
if a = 'ListView1' then begin
.......
exit;
end;
if a = 'ListView2' then begin
.......
exit;
end;
if a = 'ListView3' then begin
.......
exit;
end;
if a = 'ListView4' then begin
.......
exit;
end;
我现在的有没办法共用啊
begin
with TListView(PopupMenu1.PopupComponent) do
begin
AddItem('DoSomething',nil);//这是举例应用
//.....
end;
end;上面是用的with开域语句。如果不用,就是这样:procedure TForm1.Pop1_1Click(Sender: TObject);
begin
TListView(PopupMenu1.PopupComponent).AddItem('DoSomething',nil);
TListView(PopupMenu1.PopupComponent).Color := clRed;
//.....上面的AddItem和改变Color等应用,都是举例,你根据自己的需要去做
end;
begin
if PopupMenu.PopupComponent is TListView then //加上这个判断
with TListView(PopupMenu1.PopupComponent) do
begin
AddItem('DoSomething',nil);//这是举例应用
//.....
end;
end;