I am modifying an application of my work. It is made in VB6, the idea is that I get an OK or an error by means of a winsock, and I must dump that state to a row in a listview.
I have achieved almost that it works, when I receive, I look in the rows of the listview if the id or name of the record exists, and if so I only modify if it is Ok or Type of Error, but I can not reflect that state changing the image from the first column.
I have the listview1 linked to an imagelist1, where I inserted 2 images:
- the 1st is index 1 key estado_ok
- the second index 2 state_err
I need to be able to change the icon at run time. I pass the code involved:
Private Sub Form_Load()
Dim ch As ColumnHeader
With ListView1
.ColumnHeaders.Clear
.ListItems.Clear
.View = lvwReport
.SmallIcons = ImageList1
.SortKey = 0
.SortOrder = lvwAscending
.Sorted = True
Set ch = .ColumnHeaders.Add(, , " Equipo", 1700)
Set ch = .ColumnHeaders.Add(, , "Estado", 1700)
Set ch = .ColumnHeaders.Add(, , "Fecha reporte", 2300, lvwColumnCenter)
Set ch = .ColumnHeaders.Add(, , "Tickets", 1074, lvwColumnCenter)
End With
Label1 = Winsock1.LocalIP
' ReDim acumulado(0)
'Cargo parámetros winsock y oculto el form1
Call Carga_Inicial
'Habilito el systray oculto y ok
Call Carga_Ok(1)
End Sub
And here is where I should change the icon, and everything I tried gives me an error
If cadena(1) <> "Impresora Ok !" Then
ListView1.SmallIcon = ImageList1.ListImages.Item(1)
Else
ListView1.SmallIcon = ImageList1.ListImages.Item(2)
End If
I know it's very bad, but I can not find it back.