私が知りたい CheckedChanged イベントでは、どのアクションがこの変更をトリガーしたか、ユーザーが明示的にチェック ボックスをクリックしたか、データ バインディングから更新されたかのいずれかです。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Source = new ValueSource();
this.checkBox1.DataBindings.Add(new Binding("Checked", Source, "State", false, DataSourceUpdateMode.OnPropertyChanged));
this.checkBox1.CheckedChanged += new EventHandler(checkBox1_CheckedChanged);
}
void checkBox1_CheckedChanged(object sender, EventArgs e)
{
// databinding changed the value.
MessageBox.Show("Value changed from data binding");
// user checked the check box using mouse.
MessageBox.Show("Value changed due to use action");
}
public ValueSource Source { get; set; }
}
public class ValueSource
{
private bool state = true;
public bool State
{
get { return state; }
set { state = value; }
}
}