using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.IO; namespace NewTest { public class PublicValue { public static string FileName; public static int[] aa; } /// <summary> /// Description
可在父窗体中定义一个全局变量 public static Form form; 然后在秀出子窗体的点击事件中增加加下代码 if (form == null) { //窗体不存在时,实例化子窗体,并显示出来,CurrentBalance为子窗体名 form = new CurrentBalance(); form.Show(); } else { //窗体已经存在时,激活窗体 form.Activate(); } //在子窗体的FormClosing事件中,加入如下代码,清空父窗体中的form变量
procedure SetTransparentForm (popupFrm:TForm;Color:TColor;AlphaBlendValue:Integer); var FrmTransparent: TFrmTransparentForm; begin if not Assigned(FrmTransparent) then FrmTransparent:=TFrmTransparentForm.Create(nil); FrmTransparent.fPopupForm :=popup
//窗体Showmedol 遇到的奇怪异常: cannot make a visible window model //背景:ShowModal A窗体,A窗体再ShowModal B窗体:A是透明背景窗体,B是提示窗体: //第一次使用该全局变量,使用完毕后,FreeAndNil,目的是不影响第二次使用(和重新初始化属性) if not Assigned(frmAd) then frmAd := TfrmAd.Create(nil); frmAd.SetUrl(r46002.Data.URL)
多窗体:一.首先要想到的问题是:1.哪个是主窗体问题:主窗体隐藏了,关闭其它窗体后,没有将主窗体显示/关闭,那么程序就关不上了 方法:用构造函数传值,将窗体传到另一个窗体中去 Form1: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
制作登录窗体: 制作一个登陆窗体,实现点击按钮关闭此窗体并打开另一个窗体 直接在按钮点击事件中,实例化一个想要打开的窗体 使用show方法打开,并把登陆窗体的visible属性改为false Form1 f1 = new Form1(); f1.Show(); this.Visible = false; 登陆界面 namespace WindowsFormsApplication1 { public partial class Login : Form { public string usern