두 개의 이벤트 핸들러가 동일한 양식의 단추에 연결되어 있습니다. 메서드가 실행되는 동안 폼을 비활성화하고 waitCursor를 표시 한 다음 폼을 활성화하고 커서를 다시 기본값으로 설정하려고합니다.동일한 양식의 두 이벤트 핸들러는 다르게 작동합니다.
이상한 부분이 있습니다. 거의 동일한 코드로 이러한 이벤트 중 하나가 작동하고 다른 이벤트는 작동하지 않습니다! 여기서 무엇이 잘못 될 수 있습니까?
이것은 작동합니다.
private void btnExceptionReport_Click(object sender, EventArgs e)
{
lblStatus.Text = "Printing exception report.";
ActiveForm.Cursor = Cursors.WaitCursor;
//Form.ActiveForm.Enabled = false;
if (DatabaseOps.printItemReport("Exceptions", cboEmployee.Text))
{
lblStatus.Text = "Exception report printed.";
}
else
{
MessageBox.Show("Error printing exception report.");
lblStatus.Text = "Error printing Exception report.";
}
//Form.ActiveForm.Enabled = true;
ActiveForm.Cursor = Cursors.Default;
}
내가 ActiveForm
이 null
이 아니라는, 다시 기본 커서를 변경하려고하면이 하나가 오류가 발생하는 동안
private void btnWIPReport_Click(object sender, EventArgs e)
{
lblStatus.Text = "Printing WIP Materials report.";
ActiveForm.Cursor = Cursors.WaitCursor;
//Form1.ActiveForm.Enabled = false;
if (DatabaseOps.printItemReport("WIP", cboEmployee.Text))
{
lblStatus.Text = "WIP Materials report printed.";
}
else
{
MessageBox.Show("Error printing WIP Materials report.");
lblStatus.Text = "Error printing WIP Materials report.";
}
//Form1.ActiveForm.Enabled = true;
ActiveForm.Cursor = Cursors.Default; //This line gives error saying ActiveForm is null
}
-이 기능이 작동합니다! 왜 그런지 알아? 이유를 설명해 주시겠습니까? 나는 여기에서 신비가있다. – MAW74656
"WIP"보고서는 응용 프로그램에서 집중력을 떨어 뜨리고 있습니다. 그래서 ActiveForm은 null이기 때문에 어떤 폼도 활성화되어 있지 않습니다. –
그래도 WIP가 예외적으로 예외 보고서를 작성하는 이유는 무엇입니까? – MAW74656