在我的program.cs中,我有这个:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
String user = null;
using (var login = new loginForm())
{
user = login.returnUser();
if (login.ShowDialog() != DialogResult.OK) return;
}
Application.Run(new Form1(user));
}
我正在尝试从我的loginForm中获取一个字符串,然后将其发送到Form1。但是字符串没有返回任何内容。
这是“ login.returnUser();”
public string returnUser()
{
String user = usernameText.Text;
return user;
}
这应该正确吗?
returnUser()
在显示对话框之前先打电话。
您如何看待它具有价值?
您只想在用户键入内容后执行此操作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句