There is no concept of session variables in Windows Forms. You can do:
Create a static class that holds the user name and password and any other variables needed across the application.
In your case it would be something like:
public static class LoginInfo
{
public static string UserID;
}
Now you can access the UserID simply from anywhere in your code:
MessageBox.Show(LogInfo.UserID);
Or set the values after login like:
LogInfo.UserID = TextBox1.Text;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…