0% found this document useful (0 votes)
7 views1 page

Complete-Reference-Vb Net 93

Uploaded by

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

Complete-Reference-Vb Net 93

Uploaded by

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

Arranging the Forms

' Get the active child form.


Dim activeChild As Form = Me.ActiveMDIChild

' If there is an active child form, find the active control, which
' in this example should be a RichTextBox.
If (Not activeChild Is Nothing) Then
Try
Dim textBox As TextBox = _
Ctype(activeChild.ActiveControl, RichTextBox)
If (Not textBox Is Nothing) Then
' Put selected text on Clipboard.
Clipboard.SetDataObject(textBox.SelectedText)
End If
Catch
MessageBox.Show("Please select TextBox.")
End Try
End If
End Sub

Arranging the Forms

If you provide the user with the ability to open more than one form, you'll want to provide the ability to
arrange the forms automatically. The built−in options you have for arranging all the forms as a collection are
Tile, Cascade, and Arrange.

You can provide the arranging facility by reference any one of the MDILayout enumeration values that cause
the child forms to arrange as you specify. The enumeration values let you arrange the child forms as
cascading, as horizontally or vertically tiled, or as child form icons that are fanned out along the lower portion
of the MDI form in a minimized state.

You can also use constructs such as the event handlers called by a menu item's Click event. This lets you
create a menu item, such as Cascade Windows, that provides the effect of cascading child MDI child
windows.

To arrange child forms, create a method to set the MDILayout enumeration for the parent. The following
code demonstrates referencing the Cascade constant of the MDILayout enumeration for the child windows
of the MDI parent form. You will typically use the enumeration in your code as follows:

Protected Sub CascadeWindows_Click(ByVal sender As System.Object, _


ByVal e As System.EventArgs)
MainForm.LayoutMDI(System.Windows.Forms.MDILayout.Cascade)
End Sub

That's about as far as I need to take you with MDI applications. The rest of the chapter explores the various UI
elements you can use for building out your MDI application.

Delegating Application Startup and Shutdown

The life of your application typically begins and ends with the parent or main form. When you close the main
form, you terminate the life of the application. However, your main form does not have to become the
controlling object in the life of your application. You can relocate the entry point and delegate the
application's start up and shut down code to other objects. This can be achieved by moving the startup logic
into a separate object that only you know exists somewhere in the vast expanse of memory called the heap.

577

You might also like