【发布时间】:2020-08-04 02:08:19
【问题描述】:
主窗体包含TTabControl,它可以动态创建一些选项卡。每当我添加一个新选项卡时,都会创建一个框架并将其添加到新选项卡中。最后,我会将所有这些TTabItem 保存到TList 中。
TForm1 = class(TForm)
TabControl1: TTabControl;
procedure TForm1.AddNewTab;
var
profileFrame :TProfileFrame;
begin
profileFrame := TProfileFrame.Create(Self);
//TabItem
TabItem := TabControl1.Add();
inc(tab_name_Count);
tabItem.Text := tab_name_Count.ToString;
//
profileFrame.Parent := tabItem;
tablist.Add(TabItem);
end;
这是我的框架:
TProfileFrame = class(TFrame)
Name: TEdit;
Gender: TComboBox;
最后,如何获取框架中的 (Name) 和 (Gender) 值,并在主窗体中打印出来?如果假设我创建了 4 个选项卡,每个选项卡都有自己的框架,我怎样才能从不同的框架中获取值?我对 Delphi 非常困惑和新手。
【问题讨论】:
-
您可以将对主框架的引用传递到动态创建的框架中,或者将对新创建的框架的引用存储在主框架中(取决于您希望进行通信的方式)。
-
"tabcontrol", "frame", "add button", "name", "gender"... 为什么两个不同的帐户似乎在同一个项目上工作?相关:How to get the user input from the frame and save into txt file?
标签: delphi frame firemonkey tabcontrol tlist