在同一窗口中的两个窗体之间切换
本文关键字:两个 窗体 之间 窗口 | 更新日期: 2023-09-27 18:35:52
我有3种形式:
- 登录表格
- 注册表格
- 主窗体
该计划从Application.Run(new FormLogin());
开始
用户可以注册。为此,我使用类似的东西(按钮注册被按下)
this.Hide();
FormRegister registerForm = new FormRegister();
registerForm.StartPosition = FormStartPosition.Manual;
registerForm.Location = this.Location;
if (registerForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
// Save the information from the Registration and register
}
else
{
this.Show();
}
this.Location = registerForm.Location;
然后用户登录(有或没有注册)我开始Main Form
(按钮登录被按下)
this.Hide();
FormMain f = new FormMain(this); // give information needed
f.Show();
问题:有没有更好的方法在登录和注册框架之间切换,这样就不必打开新窗口(这需要时间)并使窗口保持其位置?
与其有 2 个单独的窗体,不如考虑将现有窗体放入 2 个不同的面板控件中,并根据需要隐藏/显示面板。