爲什麼這個簡單的代碼導致休眠錯誤:簡單的開關導致堆棧溢出
無法計算表達式,因爲當前線程處於堆棧溢出狀態。
private void barButtonPanelVisibleCheck_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
switch (barButtonPanelVisibleCheck.Checked)
{
case true:
this.navBarControl.Visible = false;
this.barButtonPanelVisibleCheck.Checked = false;
break;
case false:
this.navBarControl.Visible = true;
this.barButtonPanelVisibleCheck.Checked = true;
break;
}
//or
if (barButtonPanelVisibleCheck.Checked == true)
{
this.navBarControl.Visible = false;
this.barButtonPanelVisibleCheck.Checked = false;
}
else
{
this.navBarControl.Visible = true;
this.barButtonPanelVisibleCheck.Checked = true;
}
}
爲什麼你要改變複選框的狀態呢?憑藉用戶點擊複選框,其狀態已被修改。只要刪除這些線。 – Yuck