windows - .NET WinForms Custom Control: how to get a reference to the containing form -
windows - .NET WinForms Custom Control: how to get a reference to the containing form -
is there way, when creating winforms custom control/user control, reference @ runtime form command placed on, access various properties of form? rather not pass reference form constructor of control, as, various reasons, need maintain default constructor no parameters.
one example: have several custom controls encapsulate win32 api calls, , of calls require window handles passed parameters. able retrieve handle of containing form can pass api function.
another example: have custom command provides "toast"-style user notifications. have alternative of opening notification form in location relative location of main application form, such centered on main window, off right, etc. not possible, obviously, without knowing coordinates of main application's window.
i could resort using findwindowex()-type api calls in cases, feels kludge, , not work in cases.
does know if possible?
you can utilize control.toplevelcontrol
property.
.net windows winforms custom-controls
Comments
Post a Comment