0

Why are the ComboBox item's just a path? When I start the appl. and want to select an item from the combobox, the items are just a path. It's every time the same path, the path to the class.

Here the Code where i give the combobox the items:

drpdefContVal.Items.AddRange(Controllertype.GetAll().ToArray<Controllertype>());
drpdefContVal.ValueMember = ((controllerType = Controllertype.GetByID(CoreClass.Settings.dbDEFAULTCONTROLLERTYPEID)) != null) ? controllerType.dbTitle : "";
leppie
  • 115,091
  • 17
  • 196
  • 297
Purger86
  • 115
  • 3
  • 14

1 Answers1

0

Value Member is only one half of the coin with combo boxes.

You want to specify a Data member. This is the string property that will display for the list of items.

So within your class I assume that the string value you want to bind to is the .

Thus you want to set the Display Member property like so:

drpdefContVal.DisplayMember = "dbTitle";
Helix 88
  • 701
  • 6
  • 19
  • You should also see [PraVn's](http://stackoverflow.com/a/9522038/681819) answer for a bit more of a description. – Helix 88 Jul 14 '15 at 11:22
  • Now the combobox is just empty. – Purger86 Jul 14 '15 at 12:06
  • did you set the drpdefContVal.DataSource = Controllertype.GetAll().ToArray() – Helix 88 Jul 14 '15 at 12:25
  • Thanks @Helix88 it worked wth drpdefContVal.DataSource = Controllertype.GetAll().ToArray() But I found an other way with a method: public override string ToString(){ return this.dbTitle; } – Purger86 Jul 14 '15 at 13:35