gpt4 book ai didi

forms - Delphi - 如何从该表单上的 TFrame 内关闭表单?

转载 作者:行者123 更新时间:2023-12-03 15:22:09 26 4
gpt4 key购买 nike

在Delphi 2010中,我创建一个表单,然后创建一个TFrame,将TFrame.Parent分配给该表单,然后以模态方式显示该表单。工作正常...框架有一个 DBNavigator、一个字段 DBFields 等。当用户单击“发布/保存”时,我想自动关闭表单。我尝试了一些方法,例如 Close、Action = caFree、(DBNav.parent.parent) as TForm.Free 等,但似乎没有任何效果。如何从 TFrame 中关闭表单?

创建这个东西的代码是......

 // Create the Window
ThisWin := TEmptyFrameWin.Create(nil);

// Create the Frame for the Window
ThisFrame := TFrameUsage.Create(Application);

ThisFrame.Parent := ThisWin;

// Load the data
ThisFrame.tUsage.Open;
ThisFrame.tUsage.FindKey([StrToInt(ID)]);
ThisFrame.LoadDateFields;

ThisWin.Caption := 'Change Appointment Information';
// Only show the POST button
ThisFrame.UsageNav.VisibleButtons := [sbPost];

try
ThisWin.ShowModal;
finally
ThisWin.Free;
end;

谢谢

GS

最佳答案

从框架类中的方法中,您可以通过调用 GetParentForm 来访问宿主表单。因此,以下内容可以满足您的需求:

GetParentForm(Self).Close;

关于forms - Delphi - 如何从该表单上的 TFrame 内关闭表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18963018/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com