I can add images to a ListView on its own, however I want to add them to a ListView that already has data in it.
EG. I have a ListView connected to a table. On eof the fields is a checkbox (yes/no). In the ListView it displays as "true/false". Instead of text saying true/false I would like to write a conditional statement.
This is some of the code have:
'Image List
Public imgLstObj As MSComctlLib.ImageList
Public Sub loadImgLst()
Set imgLstObj = Me.ImageList1.Object
imgLstObj.ListImages.Add 1, "Pic 1", LoadPicture("C:\Images\QA\images\star.bmp")
imgLstObj.ListImages.Add 2, "Pic 2", LoadPicture("C:\Images\QA\images\Sad.bmp")
imgLstObj.ListImages.Add 3, "Pic 3", LoadPicture("C:\Images\QA\images\idea.bmp")
End Sub
Public Function loadIcon()
'Public Sub loadIcon()
Dim lvObj As ListView
Set lvObj = ListView2.Object
Set lvObj.SmallIcons = imgLstObj
lvObj.Icons = imgLstObj
lvObj.View = lvwSmallIcon
lvObj.ListItems.Add 1, "Pic 1", "Gold Star", "Pic 1", "Pic 1"
lvObj.ListItems.Add 2, "Pic 2", "Deviation", "Pic 2", "Pic 2"
lvObj.ListItems.Add 3, "Pic 3", "Idea", "Pic 3", "Pic 3"
Private Sub Form_Load()
Call FillJobs
Call loadImgLst
Call loadIcon
End Sub
...blah,blah,blah
rs.MoveFirst
Do Until rs.EOF
Set lstItem = Me.ListView1.ListItems.Add()
lstItem.Text = Nz(rs!GSNumber)
lstItem.SubItems(1) = Nz(rs!Company_Name, "N/A")
lstItem.SubItems(2) = Nz(rs!Job_Number, "N/A")
lstItem.SubItems(3) = Nz(Trim(rs!NoI_Improve))
lstItem.SubItems(4) = Nz(Trim(rs!NoI_Deviate))
lstItem.SubItems(5) = Nz(Trim(rs!NoI_GoldStar))
lstItem.SubItems(6) = Nz(Trim(rs!Date))
******* HERE IS THE PROBLEM *****
' Show icon based on value
If rs!NoI_Deviate.Value = "True" Then
lstItem.SubItems(4) = ?????????????
End If
How can I show an image from the ImgLst here?
EG. I have a ListView connected to a table. On eof the fields is a checkbox (yes/no). In the ListView it displays as "true/false". Instead of text saying true/false I would like to write a conditional statement.
This is some of the code have:
'Image List
Public imgLstObj As MSComctlLib.ImageList
Public Sub loadImgLst()
Set imgLstObj = Me.ImageList1.Object
imgLstObj.ListImages.Add 1, "Pic 1", LoadPicture("C:\Images\QA\images\star.bmp")
imgLstObj.ListImages.Add 2, "Pic 2", LoadPicture("C:\Images\QA\images\Sad.bmp")
imgLstObj.ListImages.Add 3, "Pic 3", LoadPicture("C:\Images\QA\images\idea.bmp")
End Sub
Public Function loadIcon()
'Public Sub loadIcon()
Dim lvObj As ListView
Set lvObj = ListView2.Object
Set lvObj.SmallIcons = imgLstObj
lvObj.Icons = imgLstObj
lvObj.View = lvwSmallIcon
lvObj.ListItems.Add 1, "Pic 1", "Gold Star", "Pic 1", "Pic 1"
lvObj.ListItems.Add 2, "Pic 2", "Deviation", "Pic 2", "Pic 2"
lvObj.ListItems.Add 3, "Pic 3", "Idea", "Pic 3", "Pic 3"
Private Sub Form_Load()
Call FillJobs
Call loadImgLst
Call loadIcon
End Sub
...blah,blah,blah
rs.MoveFirst
Do Until rs.EOF
Set lstItem = Me.ListView1.ListItems.Add()
lstItem.Text = Nz(rs!GSNumber)
lstItem.SubItems(1) = Nz(rs!Company_Name, "N/A")
lstItem.SubItems(2) = Nz(rs!Job_Number, "N/A")
lstItem.SubItems(3) = Nz(Trim(rs!NoI_Improve))
lstItem.SubItems(4) = Nz(Trim(rs!NoI_Deviate))
lstItem.SubItems(5) = Nz(Trim(rs!NoI_GoldStar))
lstItem.SubItems(6) = Nz(Trim(rs!Date))
******* HERE IS THE PROBLEM *****
' Show icon based on value
If rs!NoI_Deviate.Value = "True" Then
lstItem.SubItems(4) = ?????????????
End If
How can I show an image from the ImgLst here?