|
-
Jan 17th, 2003, 05:40 AM
#1
ListView1.SelectedItem.SmallImage = ???
I have the following:
VB Code:
Private Sub cmdLargeFish_Click()
Dim lvwItem As ListItem
Set lvwItem = ListView1.SelectedItem
If Not lvwItem Is Nothing Then
lvwItem.SmallImage = "LARGE_FISH"
Set lvwItem = Nothing
End If
End Sub
Private Sub cmdIllFish_Click()
Dim lvwItem As ListItem
Set lvwItem = ListView1.SelectedItem
If Not lvwItem Is Nothing Then
lvwItem.SmallImage = vbNullString/0 'What the heck do you put here to REMOVE/CLEAR the image??? :(
Set lvwItem = Nothing
End If
End Sub
How can I remove the image from the selected item???
Woka
-
Jan 17th, 2003, 06:14 AM
#2
-
Jan 17th, 2003, 06:18 AM
#3
PowerPoster
SmallImage = SmallIcon 
And try Null?
-
Jan 17th, 2003, 06:21 AM
#4
Arrr....got it, the listview doesn't REPAINT, so I thought 0 didn't work 
Tries a .refresh, but even that doesn't repaint the screen...any ideas???
Woka
-
Jan 17th, 2003, 06:54 AM
#5
PowerPoster
Originally posted by Pc_Madness
SmallImage = SmallIcon 
And try Null?
Am I off the track?
-
Jan 17th, 2003, 07:01 AM
#6
-
Jan 17th, 2003, 07:33 AM
#7
Frenzied Member
Other than that....the API SetWindowPos will repaint the screen
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Jan 17th, 2003, 07:44 AM
#8
Or...
VB Code:
Const RDW_INVALIDATE = &H1
Declare Function RedrawWindow Lib "user32" Alias "RedrawWindow" (ByVal hwnd As Long, lprcUpdate As RECT, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
' And to repaint...
RedrawWindow [i]Object[/i].hwnd, ByVal 0&, ByVal 0&, RDW_INVALIDATE
-
Jan 17th, 2003, 07:56 AM
#9
Frenzied Member
smartarse Ax
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Jan 17th, 2003, 08:02 AM
#10
Originally posted by Blobby
smartarse Ax
One tries one's best
-
Jan 17th, 2003, 10:30 AM
#11
Why not send the correct windows message for the listview though? 
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LVM_FIRST = &H1000
Private Const LVM_REDRAWITEMS = (LVM_FIRST + 21)
'Some function
SendMessage lvwData.hwnd, LVM_REDRAWITEMS, ByVal 0&, ByVal 0&
Does the trick perfectly by redrawing the listitems 
Cheers for the help people...
Woka
-
May 7th, 2003, 07:20 AM
#12
Hyperactive Member
More help please
Hello Woka
I have the same problem as you.
I also want to remove the smallIcon from my listview.
When I found your code I jumped high with joy, but landed hard 
with this code, it only redraws the first item in the listview, on the other items the smallicon doesnt dissapear.
Form with listview and imagelist.
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LVM_FIRST = &H1000
Private Const LVM_REDRAWITEMS = (LVM_FIRST + 21)
Private Sub Form_Load()
' Create an object variable for the ColumnHeader object.
Dim clmX As ColumnHeader
Dim intx As Integer
' Add ColumnHeaders.
Set clmX = ListView1.ColumnHeaders.Add(, , "test")
ListView1.BorderStyle = ccFixedSingle ' Set BorderStyle property.
ListView1.View = lvwReport ' Set View property to Report.
ListView1.SmallIcons = ImageList1
' Create a variable to add ListItem objects.
Dim itmX As ListItem
For intx = 0 To 10
Set itmX = ListView1.ListItems.Add(, , CStr(intx))
itmX.SmallIcon = 1 ' Set an icon from ImageList.
Next intx
End Sub
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
If Item.SmallIcon <> "on" Then
Item.SmallIcon = "on"
Else
'Remove the smallicon
Item.SmallIcon = Empty
' Item.SmallIcon = "off"
End If
'repaint the listview
SendMessage ListView1.hwnd, LVM_REDRAWITEMS, ByVal 0&, ByVal 0&
End Sub
I cant find the const that will repaint the whole listview. Do you have any idea?
Onerrorgoto
Dont be to optimistic, the light at the end of the tunnel might be a train
-
May 7th, 2003, 08:09 AM
#13
-
May 7th, 2003, 08:46 AM
#14
Hyperactive Member
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
|