Ciao
Ti stai complicando la vita: perchè cambi la proprietà CheckOnClick? Potresti semplicemente impostarla su true e quindi gestire l'evento CheckedChanged:
private void btnConfCosti_CheckedChanged(object sender, EventArgs e)
{
if (this.btnConfCosti.CheckState == CheckState.Checked)
{
this.ModoConfCosti = false;
}
else if(this.btnConfCosti .CheckState == CheckState.Unchecked)
{
this.ModoConfCosti = true;
}
}
Oppure la imposti a false e gestisci solo l'evento Click:
private void btnConfCosti_Click(object sender, EventArgs e)
{
if (this.btnConfCosti.CheckState == CheckState.Checked)
{
this.btnConfCosti.CheckState = CheckState.Unchecked;
this.ModoConfCosti = false;
}
else
{
if (this.btnConfCosti.CheckState == CheckState.Unchecked)
{
this.btnConfCosti.CheckState = CheckState.Checked;
this.ModoConfCosti = true;
}
}
}
Luca