K klarsys Active Member Licensed User Longtime User Jan 7, 2016 #1 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?
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?
stevel05 Expert Licensed User Longtime User Jan 7, 2016 #2 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. B4X: 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: Jan 7, 2016 Upvote 0
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. B4X: 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