///////////////在程序入口文件(一般是Program.cs)中这样写//////////// using System; using System.Collections.Generic; using System.Windows.Forms; namespace CCRegister { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { //*****主要看下面************ //你的登陆窗口frmLogin Form login = new frmLogin(); if (login.ShowDialog() == DialogResult.OK) { //你准备新打开的窗口frmMain Application.Run(new frmMain()); } } } } //////////////在你的登陆窗口验证成功的代码后面写///////
这样关闭form1之后可以操作form2
this.Hide();
new Form2().Show();
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace CCRegister
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
//*****主要看下面************
//你的登陆窗口frmLogin
Form login = new frmLogin();
if (login.ShowDialog() == DialogResult.OK)
{
//你准备新打开的窗口frmMain
Application.Run(new frmMain());
}
}
}
}
//////////////在你的登陆窗口验证成功的代码后面写///////
this.DialogResult = DialogResult.OK;//成功//相信可以解决你的问题
myForm.ShowDialog();
this.Close();