Do you want the user to be able to still work with the main Form while the
child Form is open, or is it acceptable to open the child Form in a modal
state?
If you're showing the child Form using the ShowDialog method, modal, then
you may consider exposing the appropriate information using custom
properties, in the same way that the common dialogs work. Assuming that you
have an "OK, Cancel, Apply" setup in your dialog, then you may want to
expose an "Apply" event from the dialog that the main Form can hook before
showing the child. Handling the "OK" and "Cancel" of the dialog would work
as usual for a common dialog.
if (child.ShowDialog() == DialogResult.OK)
{
// Then the user wants the changes to be applied/committed.
}
So in the above scenario you'd need to create some custom properties, or
just one if you're exposing all the information through a custom class
instance, and one custom event. This is like option "(2)".
--
Tim Wilson
..Net Compact Framework MVP
[quoted text, click to view] "JezB" <jezbroadsword@blueyonder.co.uk> wrote in message
news:O2wO7ItYFHA.3864@TK2MSFTNGP10.phx.gbl...
> I'm new to windows forms, and I'm a bit puzzled how to add child windows
to
> the main window and interact between them. In my case I just want to open
up
> an Options window which, depending on what the user does in there, affects
> things on the main window.
>
> There's no ChildWindow control as far as I can see so I assume I'll have
to
> create my Options window as a new Form object and create it and show it
from
> my main form. But I want to apply changes to my main window from the
options
> window. So as I see it I can either:
>
> (1) pass a reference to the master form to my child form and within code
on
> my child form make changes directly to the controls on the master form -
of
> course to do this I have to make those controls public, or
>
> (2) create delegates and events on my child form and subscribe to those
> events on my main form, so that I can manipulate the controls via code on
> the master form.
>
> Both these approaches seem more complex that it really should be ! Is
there
> an easier way or am I missing something ?
>
>
>