13 December 2006

BindingList

Binding is very useful stuff but I often forget of using it. The last time was different, I used and I met a little problem with synchronizing ListBox with List. Adding a new object to the list did not have any effect in my ListBox control. So I went to speak with my friend - google. He said that I should use a BindindList instead of List. I did it and it really works. The code looks like:

1 public class FrmMain : Form

2 {

3 private BindingList _objects;

4

5 private FrmMain()

6 {

7 InitializeComponent();

8

9 this._objects = new BindingList();

10

11 this.lbObjects.DataSource = this._objects;

12 this.lbObjects.DisplayMember = "Name";

13 this.lbObjects.ValueMember = "Id";

14 }

15 }

0 Comments:

Post a Comment

<< Home