0
ComboBoxはBindingSourceにバインドされていますが、これはLinqテーブルにバインドされています。ComboBoxとLinq to Sql for Winforms
また、ComboBoxはLinqテーブルであるデータソースから塗りつぶされます。
ユーザーがComboBoxでアイテムを選択するたびに、BindingSource.Currentのプロパティの1つに新しい値を割り当てたいとします。私はComboBoxのSelectionChangeCommittedイベントを使用する必要があることをMSDNから理解しました。ここで
は擬似コードです:myCB_SelectionChangeCommitted(...)
{
var val = myCB.SelectedValue; //I get selected value from user.
var q = bindingSource.Current as XYZ;
//Ommitted validation code to check if q is okay to work with
q.SomeProperty = NewCalculatedValue; //SomeProperty is bound to label
//After above line, myCB.SelectedValue is lost!
//It seems that this event fires **before** selected value
//is written to bound data source
}
は私がmyCB.DataBindings [0] .WriteValue()を使用する必要があります。 ?それとも良い方法がありますか?
ありがとうございます。