有没有办法让我的主表单 form1 在表单 2 加载后显示?自动加载这是表格 2 代码
private void button1_Click(object sender, EventArgs e)
{
string username1 = "Richard";
string password1 = "Peugeot";
if (this.textBox1.Text == username1 && this.textBox2.Text == password1)
MessageBox.Show("Welcome Richard!", "Welcome");
else
MessageBox.Show("Incorrect username or password", "Bad credentials");
}
这是form1代码
private void Form1_Load(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder(String.Empty);
sb.AppendLine("Operation System Information");
sb.AppendLine("----------------------------");
sb.AppendLine(String.Format("Name = {0}", OSVersionInfo.Name));
sb.AppendLine(String.Format("Edition = {0}", OSVersionInfo.Edition));
if (OSVersionInfo.ServicePack!=string.Empty)
sb.AppendLine(String.Format("Service Pack = {0}", OSVersionInfo.ServicePack));
else
sb.AppendLine("Service Pack = None");
sb.AppendLine(String.Format("Version = {0}", OSVersionInfo.VersionString));
sb.AppendLine(String.Format("ProcessorBits = {0}", OSVersionInfo.ProcessorBits));
sb.AppendLine(String.Format("OSBits = {0}", OSVersionInfo.OSBits));
sb.AppendLine(String.Format("ProgramBits = {0}", OSVersionInfo.ProgramBits));
textBox1.Text = sb.ToString();
}
这是 program.cs 代码
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form2());
}
}
我希望表格 1 在表格 2 之后自动加载 在此先感谢