Android Question Common handler for _Click event?

klarsys

Active Member
Licensed User
Longtime User
Is there any way to have a common handler for _Click event for multiple buttons and then call relevant function based on which button was clicked? I guess name / id / text of clicked button can be obtained from Sender object?
 
Yes use the Sender object. Use the buttons tag to identify which button was pressed:

Set the same EventName in the designer, or initialize the buttons to the same EventName if you are creating them in code.

Code: Copy
Sub Common_Click

    Dim B As button  = Sender

    Select B.Tag
        Case 1
             'Do Something
        Case 2
            'Do Something Else
    End Select

End Sub

Where 1 & 2 are values of the Tags
 
Last edited:
Upvote 0
Back
Top