Fill Listbox

  • Thread starter Thread starter Terry
  • Start date Start date
T

Terry

I would like to fill a listbox with a 2 column valuelist and hide the value
in the first column as available in VBA. I have tried .items.add and
item.addrange but cannot seem to get the desired result. I am using the form
Load event to fill the listbox.
Regards
 
Terry said:
I would like to fill a listbox with a 2 column valuelist and hide the value
in the first column as available in VBA. I have tried .items.add and
item.addrange but cannot seem to get the desired result. I am using the
form Load event to fill the listbox.

Add the items to a "collection" ('DataTable', for example), assign it to the
control's 'DataSource' property and set its 'DisplayMember' and
'ValueMember' properties according to your needs.
 
Its not very often I agree with Herfried, but I do in this situation.

OMG! I am slipping! Help!!!!!!!!!!!!!!!!!!!!!!
 
Terry,

For this you have to fill class objects to the itemlist from a listbox.

You have to cast those when you need them. In fact you can use endless
columns.

(I normally give always the samples of datatables and than comes Herfried
with this class/object answer, I was supprised that he gave now my standard
answer).

Cor
 
I would like to fill a listbox with a 2 column valuelist and hide the value
in the first column as available in VBA. I have tried .items.add and
item.addrange but cannot seem to get the desired result. I am using the form
Load event to fill the listbox.
Regards

Me.myList.Items.Add(New ListItem("My_Display_Text",
"My_Hidden_Value"))

The Grand Master
 
Thanks for all the help.

I have decided to use a small SQL table which will allow me to easily add
new rows without having to re-code. I had needed to create the database for
this project so have taken this opportunity to learn something about
SQL2005.

Regards
 
Back
Top