Android Question Handle the Sender in another Sub possible, but only, if the Sender- Event Sub has an empty codeline?

Cadenzo

Active Member
Licensed User
Longtime User
I have some SwiftButtons in some items of CustomListView and want to handle the Sender only in one Sub. This works only, if I have an empty line in the SwiftButtons _Click events. Why?

Sender is empty, when no empty line:
Sub SetNotenOption(mode As Int)
    Dim sbtn As SwiftButton = Sender 'is null, if the _Click event will not have an empty code-line
    Dim iIndex As Int = sbtn.Tag' find CLV-index via .Tag, because .GetItemFromView works not with SwiftButton, only B4Xview!  clvMusicList.GetItemFromView(Sender) 'Sender von SwiftButton 1-4
    Dim t As BookItemType = clvMusicList.GetValue(iIndex)
    Main.cG.i_MusicMode = mode
    Select mode
        Case 4, 5
            SetNoten(t, False)
        Case 6
        Case 7
                    
    End Select
End Sub

Private Sub SwiftButton1_Click
    'why we need an empty line here???
    SetNotenOption(5) 'Begleitung FrmMusic.i_MOD_BEGL
End Sub

Private Sub SwiftButton2_Click
    
    SetNotenOption(4) 'Kontrolle
End Sub

Private Sub SwiftButton3_Click 'will not work, because first line in the Sub has to be empty 
    SetNotenOption(6) 'Game
End Sub

Private Sub SwiftButton4_Click
    
    SetNotenOption(7) 'Info
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Why not setting SwiftButton as eventprefix and just USE one eventsub?
Your code makes zero sense to me
 
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
I have a list with 4 SwiftButtons (4 options) in many Listitems. So the "Tag" property I need to identify the ListIndex when pressed, and can not use it, to identify the Button 1-4. That's why I use 4 event subs for every Button. This is not a problem. I just wondered, why it works only with an empty line. Just want to understand it.
 
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
It's not quite the answer of the question, but now I found this Thread. So with clv.GetItemFromView(sbtn.mBase) it is possible to get Item also from a Switchbutton and no need for using Tag property. :) šŸ‘
 
Upvote 0
Top