Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing background images on buttons

Status
Not open for further replies.
Oct 2, 2002
104
US
I have the following code...

Private Sub btnSeat1A_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSeat1A.Click, btnSeat1B.Click
btnSeat1A.BackgroundImage = _
Image.FromFile("...\Project Files\seatme.jpg")
End Sub

Now what happens is, when I click the button btnSeat1A or btnSeat1B, the background image for btnSeat1A changes.

I know I could just have 40 "on click" events, one for each button, but this seems tedious.

I have 40 buttons, and when each one is clicked, I need the background image to change for that button.

When I try:
me.BackgroundImage = _
Image.FromFile("...\Project Files\seatme.jpg")

behind the onclick event, it changes the background of the form, not the button.

what would be the easiest way to handle this?
 
Nick

When you specify Me you are referring to the top most parent object, which in your case will be the Form.

if your command button is named cmdTest, then use cmdtest.backgroudimage etc....

Sounds to me as if you need to sub-class the base command button, add a property for you on-click image, and put code in the buttons click event to apply the image.



Sweep
...if it works dont mess with it
 
You should be able to create a control array to help with the problem, but I will have to get back to you on it if you need more details.

Becca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top