String
名前int
用の と ID 番号用のを持つクラスがあります。
public class Item
{
public int IDNumber { get; set; }
public String Name { get; set; }
}
をList<Item>
作成するために使用したものがありますBindingList<Item>
。はBindingList<Item>
、私がデータバインドDataSource
した です。ComboBox
私はDisplay Member
現在、名前として、Value Member
現在 IDNumber として持っています。
を変更することはできますが、変更するName
と の値ComboBox.SelectedText
が "" になります。より明確にするために、名前は「Dave」と伝えます。ユーザーは「John」と入力します。を「ジョン」に変更したいのですSelectedText
が、代わりに「」になります。
私は使用してみましたINotifyPropertyChanged
:
public class Item : INotifyPropertyChanged
{
private String name;
public int IDNumber { get; set; }
public String Name
{
get
{
return name;
}
set
{
this.name = value;
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs("Name"));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
ComboBox
これは、フィールドを使用する前に一度クリックした後にのみトリックを実行しますがSelectedText
、変更が加えられたときに更新したいのです。
これを回避する方法を知っている人はいますか?
ありがとう。