100分求“如何从 COMBOX中动态显示 FORM”(100)

  • 主题发起人 主题发起人 vlaomao
  • 开始时间 开始时间
V

vlaomao

Unregistered / Unconfirmed
GUEST, unregistred user!
其中 FORM1,FORM2 是窗体,ANAME,BNAME 是窗体名字。cbb1.Items.AddObject('ANAME',Form1) ;cbb1.Items.AddObject('BNAME',Form2)我想要的结果是 选择 COMBOX 中 BNAME ,FORM2 就SHOW
 
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TMainForm = class(TForm) cbb1: TComboBox; procedure FormCreate(Sender: TObject); procedure cbb1Change(Sender: TObject); private { Private declarations } public { Public declarations } end;var MainForm: TMainForm;implementationuses Unit2, Unit3;{$R *.dfm}procedure TMainForm.FormCreate(Sender: TObject);var Form: TForm;begin cbb1.Clear;// Form := TForm2.Create(cbb1);// cbb1.AddItem(Form.Name, Form);// Form := TForm3.Create(cbb1);// cbb1.AddItem(Form.Name, Form); Form := TForm2.Create(cbb1); cbb1.AddItem(Form.Caption, Form); Form := TForm3.Create(cbb1); cbb1.AddItem(Form.Caption, Form); if cbb1.Items.Count > 0 then cbb1.ItemIndex := 0;end;procedure TMainForm.cbb1Change(Sender: TObject);begin if cbb1.ItemIndex >= 0 then begin if (cbb1.Items.Objects[cbb1.ItemIndex] is TForm) then TForm(cbb1.Items.Objects[cbb1.ItemIndex]).Show; end;end;end.给分!
 
procedure TForm1.ComboBox1Select(Sender: TObject);begin if cbb1.ItemIndex=1 then//1为'BNAME',Form2在cbb1中的序号 form2.show;end;
 
谢谢,其实我学到了最后一句。SHOW的过程我不知道
 

Similar threads

D
回复
0
查看
825
DelphiTeacher的专栏
D
D
回复
0
查看
831
DelphiTeacher的专栏
D
D
回复
0
查看
664
DelphiTeacher的专栏
D
D
回复
0
查看
541
DelphiTeacher的专栏
D
后退
顶部