Results 1 to 3 of 3

Thread: Return Owner from Sender Object

  1. #1

    Thread Starter
    New Member himalayan's Avatar
    Join Date
    Apr 2016
    Posts
    4

    Return Owner from Sender Object

    Hi all,

    I'm trying to dynamically retrieve the owner of a sender object.

    Let's say I have Form1, Form2, Button1 and Button2.

    I click Button1 on Form1 which Creates a New Form2 with Button2

    On creation, I want to dynamically AddHandler of Button2 which Shows a MessageBox with the Name of Form2.

    I've sorted everything so far apart from how to get this information back

    Essentially, in reality, I suppose all I'm trying to do is add the handler of msgbox(me.name) to Button2

    Does anyone have any ideas?

    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Return Owner from Sender Object

    This all sounds very contrived. What are you actually trying to achieve?

    Ignoring for the moment that what you describe doesn't really appear to achieve anything useful, are you saying that you want a method in Form1 to handle the Click event of a Button on Form2?

  3. #3
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Return Owner from Sender Object

    Assuming sender is a UI control, you can ask it for its parent form. See here.

    DirectCast(sender, Control).TopLevelControl

    something like that

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width