放一个mainmenu在窗体上。 然后双击mainmenu,建立一项,name为file1。procedure TForm1.FormCreate(Sender: TObject); var PullDownOutput:TMenuItem; Item:TMenuItem; i:integer; SelfPosition:integer; begin PullDownOutput:=TMenuItem.Create(self); PullDownOutput.Caption:='销售额'; SelfPosition:=MainMenu1.Items.IndexOf(File1); MainMenu1.Items.Insert(SelfPosition+1,PullDownOutPut); for i:=1 to 12 do begin Item:=TMenuItem.Create(self); Item.Caption:=IntToStr(i)+'月份'; PullDownOutPut.Insert(PullDownOutPut.Count,Item); end; end;
然后双击mainmenu,建立一项,name为file1。procedure TForm1.FormCreate(Sender: TObject);
var
PullDownOutput:TMenuItem;
Item:TMenuItem;
i:integer;
SelfPosition:integer;
begin
PullDownOutput:=TMenuItem.Create(self);
PullDownOutput.Caption:='销售额';
SelfPosition:=MainMenu1.Items.IndexOf(File1);
MainMenu1.Items.Insert(SelfPosition+1,PullDownOutPut);
for i:=1 to 12 do
begin
Item:=TMenuItem.Create(self);
Item.Caption:=IntToStr(i)+'月份';
PullDownOutPut.Insert(PullDownOutPut.Count,Item);
end;
end;