Delphi Prism:如何加载Winform而不显示它?

发布于 2024-12-04 05:56:23 字数 216 浏览 1 评论 0原文

我有一个 winform,需要在显示之前加载它来更新其控件的值或属性。

我发现一个 stackoverflow 问题问了同样的事情,但它的答案并没有真正帮助我。 加载表单而不显示

任何示例代码将不胜感激。谢谢你,

I have a winform that needs to be loaded to update its controls' values or properties, before it is to be shown.

I found a stackoverflow question asking the same thing, but it's answer doesn't really help me. Load a form without showing it

Any sample code will be appreciated. Thank you,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱冒险 2024-12-11 05:56:23

只需创建表单的新实例并设置控件的值。

检查此代码

Var
  AForm : ChildForm;
begin
  AForm:= new ChildForm;
  AForm.textBox1.Text:='Foo';  //this control can be accessed here  because the Modifiers property was set to public. 


  AForm.Show;
end;

顺便记住,如果您想修改或访问另一个表单的控件,您必须设置控件的属性Modifiers以访问public

Only you need create a new instance of the form and set the values of the controls.

check this code

Var
  AForm : ChildForm;
begin
  AForm:= new ChildForm;
  AForm.textBox1.Text:='Foo';  //this control can be accessed here  because the Modifiers property was set to public. 


  AForm.Show;
end;

Btw remember if you want modify or access the controls of another form you must set the property Modifiers of the control to access to public.

败给现实 2024-12-11 05:56:23

创建这样的表单:

form := new MyForm();

假设您已经在 MyForm 上实现了一个方法来更新值,请调用它:

form.Update();//may need to pass parameters here

以通常的方式显示表单:

form.ShowDialog();

Create the form like this:

form := new MyForm();

Assuming you have implemented a method on MyForm to update the values, call it:

form.Update();//may need to pass parameters here

Show the form in the usual way:

form.ShowDialog();
你列表最软的妹 2024-12-11 05:56:23

来自 MSDN:

表单.加载
在第一次显示表单之前发生。

因此,您可以在此事件处理程序中显示表单之前对控件进行所有必要的更新。

但实际上,使用数据绑定可能更好 在控件上,以便它们自动反映您希望它们显示的当前值,并且您不必编写任何粘合代码,将数据带入控件(并从控件中读取数据)。

From MSDN:

Form.Load
Occurs before a form is displayed for the first time.

So you can do all updates to the controls that are necessary before you show the form in this event handler.

But actually it is probably better to use databinding on the controls, so that they automatically reflect the current values you want them to show and you don't have to write any glue code bringing data on controls (and reading from them).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文