jeudi 13 avril 2017

Invoke Click method in DoubleClick method of ListBox

I'm trying to invoke the click method of a set of listboxes after doing a specific code for doubleclick.


Private Sub ListBox1_Click(sender As Object, e As System.EventArgs) Handles ListBox1.Click
    ' Do something 1
End Sub

Private Sub ListBox2_Click(sender As Object, e As System.EventArgs) Handles ListBox2.Click
    ' Do something 2
End Sub

Private Sub ListBoxes_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick,
                                                                                                         ListBox2.DoubleClick
    ' Do something for doubleclick

    ' Invoke Click method
    Try
        Dim result As Object = Me.GetType().InvokeMember(sender.name + "_Click",
                                                         BindingFlags.Default Or BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Instance Or BindingFlags.InvokeMethod,
                                                         Nothing, Nothing, New Object() {sender, Nothing})
    Catch ex As Exception
    End Try

End Sub

The result is a "MissingMethodException" exception

Method MyProject1.Form1.ListBox1_Click not found

But it is there, look vb, it is just there, at the top, can't you see?

Thank you for your help.





Aucun commentaire:

Enregistrer un commentaire