AddressOf with parameter

后端 未结 8 620
误落风尘
误落风尘 2021-01-07 23:33

One way or another I need to link groupID (and one other integer) to the button I am dynamically adding.. any ideas?

What I can do;

AddHandler mybutt         


        
8条回答
  •  失恋的感觉
    2021-01-08 00:20

    No problem ;-)

    For example:

    Private ComboActionsOnValueChanged As New Dictionary(Of ComboBox, EventHandler)
    
    'somewhere in function
    dim del = Sub(theSender, eventArgs)
               MsgBox(CType(theSender, ComboBox).Name & " test")
              End Sub
    ComboActionsOnValueChanged.Add(myCombo, del)
    
    'somewhere else
    Dim delTest = ComboActionsOnValueChanged(myCombo)
    RemoveHandler myCombo.SelectedValueChanged, delTest
    myCombo.DataSource = someDataSource
    AddHandler myCombo.SelectedValueChanged, delTest
    

    as we expect, event won't fire after DataSource change in this place

提交回复
热议问题