Many thanks. Works perfectly.
""Jeffrey Tan[MSFT]"" wrote:
> Hi kh,
>
> Based on my understanding, you want to update the combobox after the bound
> datasource of combobox is changed programmatically.
>
> We may just get the currencymanager of combobox, then call its Update
> method to force the re-bound, sample code like this:
> public enum CustomColor
> {
> white=0,
> red=1,
> yellow=2,
> blue=3
> };
>
> public class TestClass
> {
> private CustomColor _testprop=CustomColor.white;
> public CustomColor testprop
> {
> get
> {
> return _testprop;
> }
> set
> {
> _testprop=value;
> }
> }
> }
>
> TestClass [] arr;
> private void button1_Click(object sender, System.EventArgs e)
> {
> arr=new TestClass[4];
> for(int i=0;i<4;i++)
> {
> arr[i]=new TestClass();
> arr[i].testprop=(CustomColor)Enum.Parse(typeof(CustomColor),
> Enum.GetName(typeof(CustomColor), i));
> }
> this.comboBox1.DataSource=arr;
> this.comboBox1.ValueMember="testprop";
> this.comboBox1.DisplayMember="testprop";
> }
>
> private void button2_Click(object sender, System.EventArgs e)
> {
> this.arr[0].testprop=CustomColor.yellow;
> CurrencyManager cm=this.comboBox1.BindingContext[this.arr, ""] as
> CurrencyManager;
> cm.Refresh();
> }
> It works well on my side. Hope it helps.
> ================================
> Thank you for your patience and cooperation. If you have any questions or
> concerns, please feel free to post it in the group. I am standing by to be
> of assistance.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! -
www.microsoft.com/security > This posting is provided "as is" with no warranties and confers no rights.
>