ScottishTapWater
ScottishTapWater

Reputation: 4846

Items not showing in listbox

I've got a simple list box on my VB form and I'm adding strings to it using the standard lstBox.items.add("string") command. However, the items aren't actually showing up in the list box. If I iterate through the items collection I can see that the strings are being added. They just aren't visible in the list box. If I add items to said collection before compilation, using the IDE, they show up fine and I can delete them in the normal way. I have tried deleting and re-adding it but that hasn't helped.

Quite frankly I am stumped, because I have used listboxes hundreds of times and I can't get this to work. So any help would be appreciated.

The exact code to add items to the list is:

MainForm.lstPendingJobs.Items.Add(MainForm.currentJob)

I have tried moving this subroutine into the mainform class and that didn't help either.

Upvotes: 0

Views: 2401

Answers (2)

Tony
Tony

Reputation: 49

Could it have been that you had accidentally altered the DrawMode property from Normal to OwnerDrawFixed or OwnerDrawVariable?

This would account for the non display of the items even though they are in the list box

Upvotes: 3

Mych
Mych

Reputation: 2563

item in your case is an object. You need to get a value out of it.

Try msgbox(item.value)

Upvotes: 0

Related Questions