I have a CheckBox
in a TabControl
.
I bound the property Checked
like this :
MyCheckBox.DataBindings.Add("Checked", MyBindingSource, "IsOn", true, DataSourceUpdateMode.OnPropertyChanged);
Property isOn :
public bool IsOn
{
get
{
return _isOn;
}
set
{
bool someCondition;
// a test is done
if (value != _isOn && someCondition)
{
_isOn = value;
}
else
{
System.Windows.Forms.MessageBox.Show("Condition not OK");
}
}
}
When user click on the CheckBox
, when someCondition
is false, a message box is displayed and the CheckBox
does not change.
My problem is when user changes page in TabControl
, the message is displayed. I saw with debugger that when page changes in TabControl
, property is set to the last value tried.
What can I do to not display a MessageBox
when changing page?
Aucun commentaire:
Enregistrer un commentaire