내 응용 프로그램은 WinForms .NET 4 (C#)이며 단추 중 하나를 누르면 폼이 자동으로 닫힙니다.이상 : 단추 누르기 후 WinForms 폼이 자동으로 닫힙니다.
- 양식에는 기본적으로 수락 및 취소 버튼이 있지만 이것들은 건드리지 않습니다.
- ButtonTestConnection_Click 이벤트가 있는데이 이벤트는 클릭 할 때 작업을하지만 폼을 어떻게 든 닫습니다.
- 마우스를 사용하여 버튼을 클릭하고 있기 때문에 계단식 키 스트로크가 발생하지 않습니다.
- 이 함수에서는 DialogResult를 설정하지 않습니다.
또한이 도용을 확인하려고 시도했습니다 .Close/this.Dispose를 호출했지만 찾을 수 없습니다.
private void ButtonTestConnection_Click (object sender, System.EventArgs e)
{
this.Enabled = false;
this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
this.ProgressBar.Minimum = 0;
this.ProgressBar.Maximum = 500;
this.ProgressBar.Value = 0;
this.ProgressBar.Visible = true;
this.ButtonTestConnection.Visible = false;
try
{
while (this.ProgressBar.Value < this.ProgressBar.Maximum)
{
// Some proxy code.
this.ProgressBar.Value++;
}
}
catch
{
}
this.ProgressBar.Visible = false;
this.ButtonTestConnection.Visible = true;
this.ProgressBar.Invalidate();
System.Windows.Forms.Application.DoEvents();
System.Threading.Thread.Sleep(10);
this.Cursor = System.Windows.Forms.Cursors.Default;
this.Enabled = true;
System.Windows.Forms.MessageBox.Show(result.ToString());
}
내가 가지고 그렇지에 설정 버튼을 함께 할 수있는 뭔가가있을 수 있습니다 느낌 아마도 초점을 바꿀 것입니다. 아직 확실하지 않습니다. –
이벤트 처리기에서 모든 것을 가져 와서 한 번에 한 줄씩 추가하여 문제를 일으키는 행을 찾습니다 (이진 검색을 사용하여 최적화). –
양식의 OnFormClosing 메서드를 재정의합니다. 그것에 브레이크 포인트를 설정하고 호출 스택을 살펴 봅니다. 당신이 그것을 이해할 수 없다면 질문에 게시하십시오. –