我要在系統登錄時以一個建立好的賬套登錄,我如何才能在各個窗体中取得所登錄的賬套

解决方案 »

  1.   

    如果不是常量,只能从登录开始,每打开一个窗体就把登录信息传递下去。
    如果是常量,声明一个常量的类,在各个窗体中引用。
      

  2.   

    public class UserInf
    {
           private static string name;
           private static *** otherInf;
           ...
           public static string Name
           {
                 get{ return name;}
           }
           public static *** OtherInf
           {
                 get{ return otherInf;}
           }
           ...
           public static void Login(string name,*** otherInf,***)
           {
                this.name=name;
                this.otherInf=otherInf
                ...
           }
           ...
    }
    //在登陆验证成功后,这样记录用户信息:
    UserInf.Login(name,otherInf,***);
    //其他页勉可以这样获取用户信息:
    string username=UserInf.Name;//如果有必要,可以设计一个static的Logoff方法,清空用户信息,完成注销,就可以再次登陆
      

  3.   

    謝謝大家給小弟的幫助,問題得以解決!!