Image Back Color

gsrajan

Registered User.
Local time
Today, 08:23
Joined
Apr 22, 2014
Messages
227
I have images in my form, say, Image1 and Image2 . The default background color for all of them are white. If the user click image1, the background color has to be red. If the user click image2, the background has to change to red and the image1 retains its default color ( White ).

I have six images to loop through these. Image1 to image6. Please let me know how to do this.

Thanks for your help.
 
the background colour is only visible if there is no image so I don't think you can do what I think you want to do - what you might consider is making the border thicker and changing that colour instead. However the code you need is as follows:

in each image control on click event put the following code - modifying which one gets the red background

Code:
image1.backcolor=vbRed
image2.backcolor=vbWhite
image3.backcolor=vbWhite
image4.backcolor=vbWhite
image5.backcolor=vbWhite
image6.backcolor=vbWhite

if you do the borders you might use something like

Code:
image1.bordercolor=vbRed
image2.bordercolor=vbBlack
image3.bordercolor=vbBlack
image4.bordercolor=vbBlack
image5.bordercolor=vbBlack
image6.bordercolor=vbBlack
image1.borderwidth=120
image2.borderwidth=20
image3.borderwidth=20
image4.borderwidth=20
image5.borderwidth=20
image6.borderwidth=20
 
Thank you. But I need if the user click the image2, image 2 should get the red back color and the white should go back to white. In short, whatever image is clicked, that back color gets red and other images are white.

Thank you.
 
Thank you. But I need if the user click the image2, image 2 should get the red back color and the other images should go back to white. In short, whatever image is clicked, that gets red and other images are white.

Thank you.
 
But I need if the user click the image2, image 2 should get the red back color and the other images should go back to white
Do you not understand this?
the background colour is only visible if there is no image
If you do, please try rephrasing your question and perhaps upload an example of what you are trying to achieve, it may be I've not understood
 
Thank you. It may be very simple to you. I have six images in the form. All images has the same back color (Example. blue ). If one image is clicked, that's back color changes to red. If the next image is clicked, the second image back color become red and the previous image back color become blue. Basically, only one image which is clicked has the red back color and other images have blue back color. I wish to achieve this without select statement or if statement.

Thank you.
 
Try two Functions:

Code:
Function ImageGotFocus()
    With Screen.ActiveControl
        .BackColor = RGB(188, 232, 163)
    End With
End Function

Code:
Function ImageLostFocus()
    With Screen.ActiveControl
        .BackColor = RGB(255, 255, 255)
    End With
End Function

Simon
 
Thank you very much. This is what I have been looking for.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom