0% found this document useful (0 votes)
30 views11 pages

PPK Pertemuan 05

This document discusses displaying Windows forms in different modes and managing the relationship between parent and child forms. There are two main modes for displaying forms: modal and modeless. Modal forms must be closed before interacting with other forms, while modeless forms allow multitasking. The owner/owned relationship establishes behaviors like minimizing/maximizing forms together and closing owned forms when the owner closes. Overloading constructors can help with communication between forms.

Uploaded by

Ryan EL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views11 pages

PPK Pertemuan 05

This document discusses displaying Windows forms in different modes and managing the relationship between parent and child forms. There are two main modes for displaying forms: modal and modeless. Modal forms must be closed before interacting with other forms, while modeless forms allow multitasking. The owner/owned relationship establishes behaviors like minimizing/maximizing forms together and closing owned forms when the owner closes. Overloading constructors can help with communication between forms.

Uploaded by

Ryan EL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Windows Form Interaction

Adding New Windows Form


• We can add new forms in a same project
Displaying Windows Forms

• A windows forms can be displayed in 2 mode:


– Modal (Dialog Box)
– Modeless
Displaying Windows Forms

• Overload constructor solves “communication


problems” with initial form
Displaying as Modal

• Using Form.ShowDialog method

• Typically used to prompt the user for data


that is then used by the application

• Must be closed or hidden to continue working


with the rest of the application

• Manage Form.DialogResult property to


determine how the forms is closed
Displaying as Modal
Displaying as Modeless
• Using Form.Show method

• Allow user shift the focus between the form


and another form without having to close the
initial form

• User can continue to work elsewhere in any


application while the form is displayed

• Use modeless forms to display frequently used


commands or information
Owner/Owned Relationship

• When a child window is opened by a parent


window by calling ShowDialog, an implicit
relationship is established between both
parent and child window
• This relationship enforces certain behaviors,
including with respect to minimizing,
maximizing, and restoring
Owner/Owned Relationship

• When a child window is created by a parent


window by calling Show, however, the child
window does not have a relationship with the
parent window
• This means that:
– The child window does not have a reference
to the parent window
– The behavior of the child window is not
dependent on the behavior of the parent
window
Owner/Owned Relationship

• Ownership allows the user to create a


relationship between a child window and a
parent window
• Can be established by assigning the Owner
property of a window
Owner/Owned Relationship
• Once this ownership is established, the following
behaviors are exhibited:
– If an owner window is minimized, all its owned windows are
minimized as well.
– If an owned window is minimized, its owner is not
minimized.
– If an owner window is maximized, both the owner window and
its owned windows are restored.
– An owner window can never cover an owned window.
– Owned windows that were not opened using ShowDialog are
not modal. The user can still interact with the owner
window.
– If you close an owner window, its owned windows are also
closed.
– If an owned window was opened by its owner window using
Show, and the owner window is closed, the owned window's
Closing event is not raised.

You might also like