Method does not have same signature etc...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anil Gupte

    #1

    Method does not have same signature etc...

    I created a button dynamically and added an event hander as follows:
    AddHandler newbtnPick.Clic k, AddressOf newbtnPick_Clic k

    Private Sub newbtnPick_Clic k()

    End Sub

    I get an error:
    Method 'Public Sub newbtnPick_Clic k()' does not have the same signature as
    delegate 'Delegate Sub EventHandler(se nder As Object, e As
    System.EventArg s)'.

    So of coutse I added
    ByVal sender As Object, ByVal e As EventArgs

    to give me
    Private Sub newbtnPick_Clic k(ByVal sender As Object, ByVal e As EventArgs)

    End Sub

    In fact even this does nto work:
    Private Sub newbtnPick_Clic k(ByVal sender As Object)

    End Sub

    Why do I need the second parameter? And I am curious, how does it know I
    will need the sender object?

    Thanx,

    --
    Anil Gupte
    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

    www.icinema.com


  • Mattias Sjögren

    #2
    Re: Method does not have same signature etc...

    >Why do I need the second parameter? And I am curious, how does it know I
    >will need the sender object?
    You need to make sure the method signature matches the delegate
    signature. It doesn't matter if you're actually going to use the
    parameters in your code or not.


    Mattias

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    Working...