Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox Setting max items not working

Status
Not open for further replies.

fissidens

Programmer
May 6, 2002
44
GB
This is really strange. I use a listbox to show an error log on a FIFO basis. The listbox is limited to 300 items by testing Listcount each time and removing the earliest item if necessary:

With mListBox
.AddItem LogItem
If .ListCount > 300 Then .RemoveItem 0
End With

This works fine on my development PC but on the target PC I only get about 45 items visible on the list!

There are about 20 lines in the box at any one time and the vertical scroll bar should allow the user to see the rest of the 300 lines. Each line is only about 20 chars long, the list is not sorted (obviously) and the IntegralHeight is set to False. Any suggestions?
 
hi

may be u only got 45 logs

or get the logs from the targetpc and try it on urs

or may be i did not get ur Q?
must be one of the three
 
You might do some things to be sure that the listbox is only listing 45 items of a 300 item set. For example, try printing logitem to a text box as well as doing additem, and see if all the items appear in the text box. If they do, then the problem is with the list box, if they don't, you know to look elsewhere.

HTH

Bob
 
Thanks for thinking about this one. There is no doubt the latest log is being written because it's there in the listbox - clearly visible as the last line. The problem is that I would like to be able to see the previous 299 as well and basically I can only see 44. The scroll bar works and is about half the height of the list box as you would expect since the height of the box is only sufficient to show 20 items. It all looks fine except I know I have put 300 items in that box, I also know that when I add a new log item it deletes the first.
One other thing, I'm ensuring that the last line written is always on-screen by setting the TopIndex property to the ListCount - 5. My understanding is that this only affects the display, not the contents.
 
I put up a listbox with 300 items in it, and it works fine in the IDE and compiled. So, it isn't some weird problem with the listbox control, anyway. You might try setting up a test form that just populates the listbox with 300 items, and then deploy the test to your target pc. If that works, then add in bits of functionality one thing at a time, and keep deploying them to your target pc and testing them. Tedious, but you should be able to narrow it down.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top