Jigit
asked on
How to discover the originator control of form closing?
Hello, Experts!
I'd like to know what control caused the form to be closed. For eaxample, was it the "X", or some else button on hte form.
Thanks
I'd like to know what control caused the form to be closed. For eaxample, was it the "X", or some else button on hte form.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
gregasm,
It didn't matter if I closed the form via the X button, a button using Me.Close, or from the Task Manager. The sender was always Form1.
~IM
It didn't matter if I closed the form via the X button, a button using Me.Close, or from the Task Manager. The sender was always Form1.
~IM
ASKER
Idle_Mind, thanks for your answer. It does work. And you are absolutely right - the sender is always the Form.
Set a break point somewhere in the event handler.
Then in the immediates window, examine the sender parameter. (sender as Object).
This is the sender who raised the close event.
Try this:
if typeof(sender) is button then
elseif typeof(sender) is textbox then
elseif typeof(sender) is label then
end if
etc...