我有winform app,它有主表单和日志表单。当显示记录表单时,我希望它具有焦点,直到它将被关闭。我试过了:
loggingForm = new LoggingForm();
loggingForm.FormClosing += loggingForm_FormClosing;
loggingForm.bOK.Click += bOK_Click;
loggingForm.Show();
loggingForm.Activate();
loggingForm.Focus();
loggingForm.TopMost = true;
loggingForm.TopMost = false;
void loggingForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (isValidPass)
e.Cancel = false;
else
e.Cancel = true;
}
答案 0 :(得分:2)
试试这个:
loggingForm.ShowDialog();