在写 popupmanu.items.add() 时提示: add()里面是“TMenuItem”类该怎么写? 谢谢!

解决方案 »

  1.   

    Var
     aItem:TMenuItem;
    begin
    aItem:=TMenuItem.Create(Self);
    aItem.Parent:=PopupMenu1;
    aItem.Name:='NewAdd01';
    aItem.Caption:='我是新加的!';
    PopupMenu1.Items.Add(aItem);
    end;
    大量电脑书籍下载:
    http://www.netyi.net/in.asp?id=ForMoreU
      

  2.   

    不好意思:把
    aItem.Parent:=PopupMenu1;
    一行去掉!
      

  3.   

    给你贴一份源代码,在Form上放一个Button、一个PopupMenu:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      Menus, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        PopupMenu1: TPopupMenu;
        aaa1: TMenuItem;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
        Procedure MyClick(Sender:TObject);
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    Var
     aItem:TMenuItem;
    begin
    aItem:=TMenuItem.Create(Self);
    aItem.Name:='NewAdd01';
    aItem.Caption:='我是新加的!';
    aItem.OnClick:=MyClick;
    PopupMenu1.Items.Add(aItem);
    end;procedure TForm1.MyClick(Sender: TObject);
    begin
    ShowMessage('哎哟,你点了我了!');
    end;end.
      

  4.   

    var
      mu_Menu1:Tmenuitem;
    begin
      mu_Menu1:=tmenuitem.Create(popupmenu1);
      mu_Menu1.Caption :='ss23';  popupmenu1.Items.Add(mu_menu1);end;
      

  5.   

    呵呵,delphi迷写的真有意思也感谢hr168谢谢你们人的帮忙,问题解决了,谢谢!!!