tvtech
asked on
Retaining index of current image
This question relates to PAQ https://www.experts-exchange.com/questions/22062589/Load-image-array.html
of which I seem to have lost the plot.
The answer that Idle_Mind gave me in that PAQ allows me to displays an array of thumbnail images, loaded from a folder.
My question is; how do I retain the index of the current image so that I can show/remove a border around the currently selected image, but turn off the border of the 'old' image?
Thanks.
of which I seem to have lost the plot.
The answer that Idle_Mind gave me in that PAQ allows me to displays an array of thumbnail images, loaded from a folder.
My question is; how do I retain the index of the current image so that I can show/remove a border around the currently selected image, but turn off the border of the 'old' image?
Thanks.
ASKER
Thanks I_M
That code will make all non-selected PictureBoxes turn white (Obliterates images) and the current image turns blue. The Labels are not displayed in my code. I basically only need a highlighter around the current image. Where did I go wrong? :-(
Thanks.
That code will make all non-selected PictureBoxes turn white (Obliterates images) and the current image turns blue. The Labels are not displayed in my code. I basically only need a highlighter around the current image. Where did I go wrong? :-(
Thanks.
ASKER
Should have shown the code....
Dim i As Integer
For i = lblThumb.LBound To lblThumb.UBound
If i = Index Then
picThumb(i).BackColor = vbBlue ' this is the selected item
Else
picThumb(i).BackColor = vbWhite ' turn "off" everything else
End If
Next
Thanks.
Dim i As Integer
For i = lblThumb.LBound To lblThumb.UBound
If i = Index Then
picThumb(i).BackColor = vbBlue ' this is the selected item
Else
picThumb(i).BackColor = vbWhite ' turn "off" everything else
End If
Next
Thanks.
You could change the appearance of the PictureBox somehow:
Private Sub picThumb_Click(Index As Integer)
Dim i As Integer
For i = picThumb.LBound To picThumb.UBound
If i = Index Then
picThumb(i).Appearance = 1 ' 3D
picThumb(i).BorderStyle = 1 ' Fixed Single
Else
picThumb(i).Appearance = 0 ' Flat
picThumb(i).BorderStyle = 0 ' None
End If
Next i
End Sub
Private Sub picThumb_Click(Index As Integer)
Dim i As Integer
For i = picThumb.LBound To picThumb.UBound
If i = Index Then
picThumb(i).Appearance = 1 ' 3D
picThumb(i).BorderStyle = 1 ' Fixed Single
Else
picThumb(i).Appearance = 0 ' Flat
picThumb(i).BorderStyle = 0 ' None
End If
Next i
End Sub
ASKER
Thanks I_M.
I know I sound dense and have not explained fully. I did the BorderStyle change earlier, but it's fairly neglible on small thumbnails, such as mine.
Basically, I want to either put a new outline around the selected image (Say using Line, or Shape etc), or otherwise highlight a Background colour, much like a coloured painting frame, if you like. Which would probably require my picThumb() to reside inside a larger Picturebox. Any of those sound doable?
Happy to increase points. :-)
Thanks.
I know I sound dense and have not explained fully. I did the BorderStyle change earlier, but it's fairly neglible on small thumbnails, such as mine.
Basically, I want to either put a new outline around the selected image (Say using Line, or Shape etc), or otherwise highlight a Background colour, much like a coloured painting frame, if you like. Which would probably require my picThumb() to reside inside a larger Picturebox. Any of those sound doable?
Happy to increase points. :-)
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If that isn't noticeable enough, then I think your idea of placing the picturebox inside another and changing the backcolor to make a "border" is the best way to go...
ASKER
That will do just fine, thanks, I_M. Good work.
The controls are part of control arrays so just loop thru and turn off everything that isn't the current item.
Something like:
Private Sub Label1_Click(Index As Integer)
Dim i As Integer
For i = Label1.LBound To Label1.UBound
If i = Index Then
Label1(i).BackColor = vbBlue ' this is the selected item
Else
Label1(i).BackColor = vbWhite ' turn "off" everything else
End If
Next i
End Sub