您可以创建一个新表单,然后使用ShowDialog函数.如果您从主表单中显示表单,它将以模式方式显示.
如果用户已通过身份验证,则以登录样式创建并关闭表单;如果用户名和密码不正确,则显示错误.
来自MSDN:
public void ShowMyDialogBox()
{
Form2 testDialog = new Form2();
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (testDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
this.txtResult.Text = testDialog.TextBox1.Text;
}
else
{
this.txtResult.Text = "Cancelled";
}
testDialog.Dispose();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3807 次 |
| 最近记录: |