将变量从主窗体传递给输入表单 [英] Passing variables from main form to input form
问题描述
任何提示?
在主窗体上添加公共资源
public bool IsDirty
{
get; set;
}
然后您可以访问 this.ParentForm.IsDirty
在您的启动表单中,
记得在显示启动窗体时传递对主窗体的引用... startupForm.showDialog(this);
I have a simple question. I have a main form, and then a startup form from where I can select a new 3D model to generate. When selecting a new 3D model from the startup form, I want to check first whether the previous model I worked on has been saved or not. I simply want to pass a boolean value from the main form to the startup form using a delegate, but I can't seem to access the main form or any of its variables. I thought it would be as simple as saying: <code>frmMain myForm = new frmMain();</code>, but typing frmMain doesn't show up anything in intellisense.
Any hints?
Add a public property on your main form
public bool IsDirty
{
get;set;
}
you can then access this.ParentForm.IsDirty
in your startup form,
remember to pass a reference to the main form when you show the startup form ... startupForm.showDialog(this);
这篇关于将变量从主窗体传递给输入表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!