vb.net - Which form opened another form -


in application, there particular form used input date range. form called many locations in application , several forms using simple testdates.showdialog() call

i center said form on form called (its parent). cannot figure out how determine form originated call.

the code below has possibilities (as test) can think of ie parent, owner, midparent , nothing.

me.location = new system.drawing.point(me.owner.location.x + (me.mdiparent.bounds.width - me.width) \ 2, me.parent.location.y + (mdiparent.bounds.height - me.height) \ 2) 

i cant use startposition.centerparent application undergoes sizing adjustment , call not center testdate form in high dpi.

is there way determine originator of call opened test dates form?

as pointed out, in order 'supply' owner, or form opened newform ensure use newform.load(me). identify me or form made call. missing in code

so looks now

me.location = new system.drawing.point(me.owner.location.x + (me.owner.bounds.width - me.width) \ 2, me.owner.location.y + (me.owner.bounds.height - me.height) \ 2) 

the above when place in form.load or form.shown sub on new form center new form on old form providing call made newform.show(me)


Comments