Get the ID/Name of a button in a click event. VB.NET

前端 未结 3 1197
忘掉有多难
忘掉有多难 2020-12-31 09:00

I have an event in VB.NET to handle several button clicks at once. I need to know which button from the selection kicked off the event. Any ideas how to do this? My code

3条回答
  •  不知归路
    2020-12-31 09:32

    You have to cast the sender to the object type expected.

     Dim btn As Button = CType(sender, Button)
    

    Then you can access what you need.

提交回复
热议问题