What is the secret to changing the backcolor property of an MDI Parent form in VB.NET?
Changing this property does not change the back color of an MDI Parent form.backcolor
Printable View
What is the secret to changing the backcolor property of an MDI Parent form in VB.NET?
Changing this property does not change the back color of an MDI Parent form.backcolor
you could try handling the Paint event in a new Thread, here's a quick working example i knocked up....
VB Code:
[Color=Blue]Private[/COLOR] [Color=Blue]Sub[/COLOR] Form1_Paint([Color=Blue]ByVal[/COLOR] sender [Color=Blue]As[/COLOR] [Color=Blue]Object[/COLOR], [Color=Blue]ByVal[/COLOR] e [Color=Blue]As[/COLOR] System.Windows.Forms.PaintEventArgs) [Color=Blue]Handles[/COLOR] [Color=Blue]MyBase[/COLOR].Paint [Color=Blue]Dim[/COLOR] t [Color=Blue]As[/COLOR] [Color=Blue]New[/COLOR] Threading.Thread([Color=Blue]AddressOf[/COLOR] pnt) t.Start() [Color=Blue]End[/COLOR] [Color=Blue]Sub [/COLOR] [Color=Blue][/COLOR] [Color=Blue] [/COLOR] [Color=Blue][/COLOR] [Color=Blue][/COLOR] [Color=Blue]Sub[/COLOR] pnt() [Color=Blue]Dim[/COLOR] bmp [Color=Blue]As[/COLOR] [Color=Blue]New[/COLOR] Bitmap([Color=Blue]MyBase[/COLOR].Width, [Color=Blue]MyBase[/COLOR].Height) bmp.SetResolution(1, 1) [Color=Blue]Dim[/COLOR] g [Color=Blue]As[/COLOR] Graphics = Graphics.FromImage(bmp) g.FillRectangle([Color=Blue]New[/COLOR] SolidBrush(Color.AntiqueWhite), g.ClipBounds) g.Dispose() [Color=Blue]MyBase[/COLOR].BackgroundImage = bmp Application.DoEvents() [Color=Blue]End[/COLOR] [Color=Blue]Sub [/COLOR]
This works too and is a little easier
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim ctl as Control
For each ctl in me.controls
If type of ctl is mdiclient then
ctl.backcolor = color.fromknowncolor(knowncolor.control)
Enf If
Next
End Sub
:rolleyes:Quote:
Originally posted by Hole-In-One
This works too and is a little easier
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim ctl as Control
For each ctl in me.controls
If type of ctl is mdiclient then
ctl.backcolor = color.fromknowncolor(knowncolor.control)
Enf If
Next
End Sub
a Form isn't a Control , so For each ctl in me.controls wont find the Form , but even if it could , you cant set the Color of an MDI Form with " .backcolor ":) , they want to change the backcolor of an MDI Form ....
the only way to change it is through graphics ;) or some serious Subclassing.Quote:
What is the secret to changing the backcolor property of an MDI Parent form in VB.NET?
See this:
http://vbforums.com/showthread.php?s...=backcolor+mdi
It does work!
As crazy as it sounds Hole-In-One's code does work I found the samething here:
http://www.dotnet247.com/247referenc.../13/66667.aspx
Although I used it in the ControlAdded event to avoid looping too often, although it is the exact samething.
VB Code:
Private Sub Form2_ControlAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.ControlEventArgs) Handles MyBase.ControlAdded If TypeOf e.Control Is MdiClient Then e.Control.BackColor = Me.BackColor End If End Sub
Sorry i was a bit slow and didn't see your post Hole.
What, were we all surprised to learn a Form is actually derived from Control?