如何把登陆界面中文本框的值存入变量在主界面中调用? 现有一个登陆界面(loginForm)和一个主界面(mainForm),想把登陆界面中文本框的值(UserName)存入变量,在主界面中调用,请问各位前辈,这个如何写,谢谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在mainForm中公开一个UserName属性//公开一个用户名属性 设为私有获取 也就是当前类内可访问public string UserName { private get; set; }loginForm登陆成功后 实例化mainForm的时候 将文本框的值赋值给mainForm的UserName 定义一个静态的类public class Globals{ public static string UserName; }在LoginForm Globals.UserName=xxx;MainFormxxx=Globals.UserName 定义一个静态的类public class Globals{ public static string UserName; }在LoginForm Globals.UserName=xxx;MainFormxxx=Globals.UserName这个是最正常的做法。PS:也是正确的。 定义一个静态的类public class Globals{ public static string UserName; }在LoginForm Globals.UserName=xxx;MainFormxxx=Globals.UserName谢谢了,是正确的。 请问如何实现C#控件像QQ头像一样闪动 关于DataGridView数据源为实体类泛型集合的问题 关于C#的一个初级问题_第一个Form DATAREADER没有关闭的问题 在XP下能正常使用,但在2000下却出现问题..请指教~ .NET windows应用程序 exe无法执行 使用VS2005发布WINFORM程序,在另外一台电脑执行安装时,提示错误 关于DataGrid的背景色设定! TreeView应用 新手求教,索引超出了数组界限问题, 菜鸟之问.关于DataTable的Merge. 数据库无法连接,怎么做?
public string UserName { private get; set; }loginForm登陆成功后 实例化mainForm的时候 将文本框的值赋值给mainForm的UserName
public class Globals
{
public static string UserName;
}在LoginForm
Globals.UserName=xxx;MainForm
xxx=Globals.UserName
public class Globals
{
public static string UserName;
}在LoginForm
Globals.UserName=xxx;MainForm
xxx=Globals.UserName这个是最正常的做法。
PS:也是正确的。
public class Globals
{
public static string UserName;
}在LoginForm
Globals.UserName=xxx;MainForm
xxx=Globals.UserName谢谢了,是正确的。