谢谢各位的帮助,昨天已经顺利完成了动态地创建POPUPMENU!菜单是一维的.但是又该如何在运行中删除动态创建的 POPUPMENU 的某个菜单项呢?代码应该如何编写呢?请各位给指点一下,先谢了!
解决方案 »
- 请各路高手们帮完成一个实例记录程序
- 请问DBChart可以实现横轴为数据库中的一列,纵轴可以显示数据库中的多条吗?即有多条曲线吗?谢谢了!!!!!!!!!!!!
- 如何让DBGRid实现此功能: 点击DBGRid的竖直滚动条时,当前记录不变?
- 在intraweb中如何像在html中一样帮背景图(用一个小图)
- 求救!!急!如何在delphi里面删除一个目录树!在线等!
- 使用sendmessage时,如何获得Twebbrowser里的html的按扭的句柄????
- (分不多了!)怎么得到当前时间?
- 请高手指点迷津!!急~~~~~~~~~~~~~~~~
- 如何用纯Api实现透明桌面图标
- 是关于数据库的问题
- 紧急求救,关于Dbgrid的!
- 请问TreeView每次动态刷新之后,如何保持它是伸展的?即不用人工干预就可以直接看到各个子节点,在线等!!!
popupmenu1.Items.Delete(i);
Put the follwing (You may need to make more than one
'MyClick' type of Procedure) : NewMenu : TPopUpMenu;
Procedure MenuPopItUp(Sender : TObject);
Procedure MyClick(Sender : TObject); Then make a your click procedure(s)Procedure TForm1.MyClick(Sender : TObject);
Begin
ShowMessage('This is my new dynamically created PopupMenu');
// Or do what evere you need to do here.
End;
// This procedure gets called when you right-click (OnMouseDown) on
// your choosen component
Procedure TForm1.MenuPopItUp(Sender : TObject);
var
mi, msub: TmenuItem;
Begin
with (Sender as TPopupMenu) do begin
// Create our first MenuItem
mi := TMenuItem.Create(self);
with mi do begin
// Lets give our new item a caption
Caption := 'First';
// Set the MyClick procedure to be 'associated'
// with this MenuItem
OnClick := MyClick;
end;
// Lets put the new MenuItem in the PopupMenu
Items.Insert(0, mi); mi := TMenuItem.Create(self);
with mi do begin
Caption := 'Sub';
msub := TMenuItem.Create(self);
with msub do begin
Caption := 'Sub1';
OnClick := MyClick;
end;
Insert(0, msub); msub := TMenuItem.Create(self);
with msub do begin
Caption := 'Sub2';
OnClick := MyClick;
end;
Insert(1, msub);
end;
Items.Insert(1, mi);
end;
End;
PopupMenu1.Items.Delete(index);
for i:=PopMenu.Items.Count-1 downto 0 do
if (PopMenu.Items[i].Caption='aaa') then
begin
PopMenu.Items.Delete(i);
end;