Changing Button.BackgroundImage

IfYouSaySo

Well-known member
Joined
Jan 4, 2006
Messages
102
Location
Hermosa Beach, CA
Programming Experience
3-5
In the following code, I am trying to get the background image for a button to change each time it is clicked. It stays the same when the click event fires. The debug traces indicate the logic is fine. I thought maybe calling Invalidate() was required, but this does not work either. Any ideas on what I am doing wrong?

VB.NET:
    Private Sub ExpanderButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExpanderButton.Click
        If Expanded = True Then
            Debug.WriteLine("Collapsing...")
            Me.BackgroundImage = My.Resources.Collapse_large
        Else
            Debug.WriteLine("Expanding...")
            Me.BackgroundImage = My.Resources.Expand_large
        End If

        ' Me.Invalidate()
        Expanded = Not Expanded
    End Sub
 
Me.BackgroundImage? Shouldn't that be ExpanderButton.BackgroundImage
 
Back
Top