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

picturebox in Listbox is lost

P: n/a
I add some picturebox in the listbox as controls like following.
Dim myPic as PictureBox
'Init myPic from here
'...
'...
for i=0 to 30
'New picturebox
'...
'set mypic property
'....
ListBox.Controls.Add(myPic)
next

When there is more PictureBox than the ListBox can display,
Vertical Scrollbar will appear. The problem is if user moves the
scrollbar up and down too fast, the picturebox in the ListBox will
disappear. Seems the controls in the listbox lost. Does anyone have
the same problem? How to solve it? Thanks!
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Limin" <li*******@gmail.com> schrieb:
I add some picturebox in the listbox as controls like following.
Dim myPic as PictureBox
'Init myPic from here
'...
'...
for i=0 to 30
'New picturebox
'...
'set mypic property
'....
ListBox.Controls.Add(myPic)
next

When there is more PictureBox than the ListBox can display,
Vertical Scrollbar will appear. The problem is if user moves the
scrollbar up and down too fast, the picturebox in the ListBox will
disappear.


What's the reason for adding pictureboxes to a listbox? If you want to
associate images with the items of a list, use a listview control instead of
the listbox control, or write an ownerdrawn listbox control that paints the
images into the items.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2

P: n/a
Thanks for your reply, Mr. Wagner.

The reason I want to add picturebox to listbox not listview is I
dynamically create picturebox, but the picturebox does not have image
information, I only use picturbox's backcolor to display different
colors. The listbox contains both text(Department Name) and color(Legend
bar for Department Name), it works fine only except if scrollbar moves
fast it will lose the picturebox.

But with listview, I need to add smallimagelist which created from ICONS
or BMPFILE, but I don't have image info. for that.

Thanks again for you help. Happy New Year!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.