Waelhi
Waelhi

Reputation: 315

animated GIF not working if Button is disabled

Just like what is said above, I'm having a problem regarding animated GIF. I have a button then if the button is clicked it show/display LOADING GIF within the button but I want that button not clickable while in the process of loading. So I use me.btn1.enabled = false but then the LOADING GIF is not working. What I mean is, it is visible but the ANIMATED LOADING GIF EFFECT not moving/working (or whatever you call that staff).

Thank you in advance!

Upvotes: 0

Views: 681

Answers (1)

Gareth
Gareth

Reputation: 2791

Leave your button enabled but change the code behind so it ignores subsequent clicks if the loading process is underway. You could use a simple state flag for this.

Dim IsLoading As Boolean

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If (IsLoading) Then
        Return
    Else
        IsLoading = True
        ' Update button with loading GIF, do loading logic etc.
    End If
End Sub

Obviously, you will need to reset IsLoading when your load is complete.

OR, hide the button when loading and show a PictureBox containing the loading GIF in its place.

Upvotes: 1

Related Questions