By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,838 Members | 2,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,838 IT Pros & Developers. It's quick & easy.

Fill Listbox

P: n/a
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
Feb 4 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Terry" <ne*******@whiteHYPHENlightDOTme.ukschrieb:
>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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 4 '07 #2

P: n/a
Its not very often I agree with Herfried, but I do in this situation.

OMG! I am slipping! Help!!!!!!!!!!!!!!!!!!!!!!

--
Newbie Coder
(It's just a name)
Feb 5 '07 #3

P: n/a
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

"Terry" <ne*******@whiteHYPHENlightDOTme.ukschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>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

Feb 5 '07 #4

P: n/a
On Feb 5, 6:22 am, "Terry" <news-g...@whiteHYPHENlightDOTme.ukwrote:
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

Feb 5 '07 #5

P: n/a
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
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ew**************@TK2MSFTNGP03.phx.gbl...
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

"Terry" <ne*******@whiteHYPHENlightDOTme.ukschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>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


Feb 6 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.