Set the selecteditem of a combobox based on key,value pair.

后端 未结 4 910
情深已故
情深已故 2021-01-27 17:32

I have a combobox that I populate like this:

this.reqTypeInput.Items.Add(new RequestType(\"Label 1\", \"Value1\"));
this.reqTypeInput.Items.Add(new RequestType(\         


        
4条回答
  •  悲哀的现实
    2021-01-27 18:12

    Lot's of choices, List, SortedList, Dictionary, SortedDictionary. But basicall you keep your collection of RequestTypes in a list and then populate the combo from it, you could even bind if you wish.

    The only thing the combo knopws about your collection of request types, is the result of each RequestType's ToString method. If you want find by Value, then Combox will only see waht you put in it, which was RequestType.ToString()

提交回复
热议问题