Binding a ComboBox to a BusinessObject

Assuming you want to display something different than what your program needs (e.g. your program needs an ID value and the user would like to see a description), you need something akin to a DictionaryEntry. The key and value pair match up to the ValueMember and DisplayMember repsectively. The following snippet shows the binding.

            edc.cb3B1Texture.Items.AddRange(TextureList.ToArray());
            edc.cb3B1Texture.ValueMember = "Key";
            edc.cb3B1Texture.DisplayMember = "Value";

...

            edc.cb3B1Texture.DataBindings.Add("SelectedIndex", this, "B_TextureID");

Here we were able to bind to the SelectedIndex, but in other cases you could bind to "SelectedItem.Key" (there is some doubt here as to weather this will work - you may have to include a cast? Not sure).

ComboBox (last edited 2009-12-30 00:20:25 by b12webproxy05)