Complete-Reference-Vb Net 93
Complete-Reference-Vb Net 93
' 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
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:
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.
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