Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Visual Basic, vb.net, help.

    Hey,

    I'm a beginner so be easy on me

    I'm creating a t-shirt designer program for my college project.



    So I've got a form with 5 different images (PictureBox) on it, the page where they choose the design of the t-shirt.

    I want the user to be able to click on one of them (and only one of them), which then highlights it (change BackColor?), then click the Next button.

    I can do this, which, when you click on the image Design1 it changes the BackColor to blue.

    Code:
    Private Sub Design1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Design1.Click
        Design1.BackColor = Color.Blue
    End Sub
    But then I need to be able to click it again to unhighlight it.

    The only thing I could think of was..

    Code:
        Private Sub Design1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Design1.Click
            Design1.BackColor = Color.Blue
    
            If Design1.BackColor = Color.Blue Then
                Design1.BackColor = Color.Transparent
            End If
        End Sub
    But obviously that just goes round in circles. Clicking it changes it to blue, then "if it's blue - change to transparent", therefore it does nothing.

    How can I do that?

    Thanks.

  • #2
    Regular Coder DELOCH's Avatar
    Join Date
    Apr 2006
    Location
    Canada
    Posts
    537
    Thanks
    4
    Thanked 2 Times in 2 Posts
    add code to the images : what happens when you click on them

    consider putting a shape in the background(default same as background), whenever someone clicks on the image, the shape color should change and reset others.

    the rest is your work

  • #3
    New Coder
    Join Date
    Jun 2008
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hm, ok thanks.

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Throw the line where you change it to blue into the else of the if statement, so it would read:
    if it's blue then set it to transparent
    else set it to blue

    Good luck.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •