I would like to know how can I transfter a string value (a name or something) from Login class over static class to Form1?
This code I have:
1. In program class:
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using (LoginForm login = new LoginForm())
{
if (login.ShowDialog() == DialogResult.OK)
{
Application.Run(new Form1());
}
}
}
}
2. In Login class, which checkes if the user has entered the correct user name and password (but here is no login code)
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();
}
private void buttonLogin_Click(object sender, EventArgs e)
{
string strUserName = textBox1.Text;
string strPassword = textBox2.Text;
bool LoginSucceeded = CheckingLogin(strUserName, strPassword);
if (LoginSucceeded)
{
//Here I would need to pass "strUserName" to Form1
this.DialogResult = DialogResult.OK;
}
}
}
I would like to know how to pass the "strUserName from LoginForm to Form1, where I would like to show, who is logged in.