Hi ! I'm using Visual Studio 2017 to do a windows form app, and I have an issue with labels and images. I'm trying to create a label that contains an arrow image (left arrow), but when the label is clicked on the arrow image has to change for the opposite arrow image (right arrow). So far I've been able to import an arrow image facing one direction on the label, but I don't know how to proceed for the part where clicking on the label changes for the opposite arrow image. Thanks !

Recommended Answers

All 6 Replies

Where to start? I can't tell where you are in your classes on VB.net apps so I'll start with a question.
Do you know how to respond to the Click Event?

What do you mean by respond to the click event ?

It's an introductory class to VB, we're pretty far now on the basics.

Thank you you for your answers !

I suggest you take a tutorial on how to respond to the click event. Me supplying code would not be helpful as you would not learn from that. Here's a start: https://www.tutorialspoint.com/vb.net/vb.net_event_handling.htm

Once you have the code in place to handle the click event for the object then you can explore how to change the image.
Example: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.label.image?view=windowsdesktop-6.0

Thank you for your help. I think I figured it out. The only last issue that I have is that it only let me do one click so one change of my arrow. I would like to do an unlimited amount of clicks.

Regarding number of clicks. Since I can't see your code I can't see why you wrote about that. Here, once we are in the handler, what we do with the following clicks is up to our code. Also, you didn't specify what should happen in this click handler on subsequent clicks.

I presume you want to toggle. In that case just check the current image and toggle to the other one. If you want to cycle through more you can use the same technique, just with more images in the cycle. I don't recall the property name, but each control has a user property which is unused by anything else and can be used to store a value indicating the current image number or name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.