-
Items? (Resolved)
Hello... Which would be the class I should use to match a ListBox and a ComboBox property of "Items"?
I tried with System.Collections.ArrayList, but it appears not to work... Any suggestions?
I have a Dictionary Class I created and I want to populate a ListBox and a ComboBox with its values or keys depending on the form I am on. How can I do this?
Thanks in advance! (Why does it tell me the Items of a ListBox is read-only?)
-
Ok, let me show you an example...
Dictionary:
Keys Values
"1" "Room 1"
"2" "Room 2"
"3" "Room 3"
And I want to have in a listBox
listBox:
Items
"Room 1"
"Room 2"
"Room 3"
And I want to have in a comboBox
comboBox:
Items
"1"
"2"
"3"
This is an example, don't think I wouldn't get the number instead of parsing it to a string.
Now let us think that Room is a Class... And I want to populate the listBox with the Name of the room... How would I be able to do this? :p Thanks again... Please help this is due tomorrow and I haven't been able to think of a solution!
Dictionary:
Keys Values
"1" aRoom1
"2" aRoom2
"3" aRoom3
aRoom1.Name = "Room 1"
aRoom2.Name = "Room 2"
aRoom3.Name = "Room 3"
listBox:
Items
"Room 1"
"Room 2"
"Room 3"
-
just add the item itself to the listbox/combobox as .Add() method accepts a object type object
-
Thanks PT Exorcist that is what I had to do at the End. I did not want to do that since I thought I could simply assign a Collection to the Collection of Items the controls had.