|
-
Sep 27th, 2001, 03:30 PM
#1
Thread Starter
Member
ListView Question!
Hi,
I do have a listview with few items and image is assigned to each item, also I do have a commandbutton(index).
My question: How can I read thru the lisbox (item by item) and chage the caption of the commandbutton by the first item, and add the icons to it, then move to th next item on the listbox, and do the same thing?
I hope I was clear enough.
Thank you,
-
Sep 27th, 2001, 03:51 PM
#2
Addicted Member
first you say listview, then listbox....since you're dealing with picture/icons, I assume you mean a listVIEW. That out of the way, I require a few other clarifications.
1) you want to change the commandbutton caption to the FIRST items name?
2)when you say "add the icons to it"....what do you mean, what do you want to add the icons to?
make things a little clearer and I'll see what I can do....
If you can think it....you can code it....
-
Sep 27th, 2001, 04:21 PM
#3
Thread Starter
Member
Thanks
Okay, I am talkling about listview. What I want to do, is to change the caption of the commandbutton with the fiest item of the listview, and the icon to the same commandbutton, then move to next item of the listview and do the samething./
for example: the items of the listview are:
new (with new icon)
open (with open icon)
result requested......
so the first commandbutton caption should be 'new' with the picture 'new' (note the commandbutton style=graphic)
then the 2nd commandbutton caption is 'open' with the open picture.
Thank you,
-
Sep 27th, 2001, 04:42 PM
#4
Addicted Member
ok, I think I understand now.....
having a listview with icons I'm assuming you also have a imagelist bound to the listview. With that said here is code that will do what you need
VB Code:
Private Sub ListView1_ItemClick(ByVal item As MSComctlLib.ListItem)
'extract that related image from the imagelist and load to commandbutton
Command1.Picture = Imagelist1.ListImages(item.index).Picture
Command1.Caption = item.Text
End Sub
Make sure you have the STYLE property for your command button set to 1 (Graphical), or you will not be able to assign icons/images to it.
Hopefully that helps!
If you can think it....you can code it....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|