I have 2 problems:
Why do I need it?
I have many forms and I need to know how the user got there. If I could get a form (not a button), it could also solve the problem.
Long version: I need to copy some properties of the original form / button to a new one without doing it manually, and I intend to use it later in the exception report to find out more information
At first I tried to do "newForm.Caller = this;" on each button, but there are 200+ forms and many buttons on each.
All forms and buttons are user controls, so I can do something there.
Tried things
I tried to do things with StackFrames and reflect on the constructor of the form, but it doesn't work ( 889310 )
I found this 10401190 for JAVA but it cannot help
I thought I could use the OnClick override to store the last instance of the button in a static place in the button / form class, and then get it in the form constructor, but this seems to be the worst solution. (Many open forms, and the culprit will be the last button pressed)
The problem gets worse when other things open Forms and I lost the link (DataGridVewButton, timers, associated label, ...)
EDIT1: (oɔɯǝɹ) Another detail, forms can be called from external plugins. Thus, I again do not have access to the code to change it.
EDIT2: (Graham Bass, ShreyasKapur)
FormA ButtonA, FormB
FormA FormBase
ButtonBase
FormB FormBase
FormA ButtonA, FormBase ButtonBase
Edit3: ( )
ShowDialog() Owner, . , !
, .
" " (1)