|
|
Title | Change the color of an MDI parent form's background |
Description | This example shows how to change the color of an MDI parent form's background in VB .NET. |
Keywords | MDI, MDI parent, background, background image, VB.NET |
Categories | VB.NET, Controls |
|
|
See Knowledge Base article 319417: HOW TO: Change the Background Color for an MDI Parent Form in Visual Basic .NET, although this version is better because it doesn't need a Try Catch block.
When the MDI parent form loads, it searches its child controls for the one that is an MdiClient. It sets that control's BackColor property to match the form's, which is set at design time.
|
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
' Set the color in the MDI client.
For Each ctl As Control In Me.Controls
If TypeOf ctl Is MdiClient Then
ctl.BackColor = Me.BackColor
End If
Next ctl
' Display a child form.
Dim frm As New Form2
frm.MdiParent = Me
frm.Width = Me.Width \ 2
frm.Height = Me.Height \ 2
frm.Show()
End Sub
|
|
|
|
|
|