-
May 5th, 2016, 02:03 AM
#1
Thread Starter
New Member
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
-
May 5th, 2016, 02:42 AM
#2
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?
-
May 5th, 2016, 03:31 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|