BackColor issue with main form and the controls
-
on a simple window form, there is a small panel, along with button and groupbox inside the panel. When I change the main window form color (i.e. this.BackColor = Color.Red) and the main form does turn red, and also the panel and groupbox were also changed to red. HUH? I just wanted the main form background color to be red, while the inside of the panel (and the panel itself) to remain unchanged. How do I do that? I tried goggling and turns out no luck. HELP!:confused::confused::confused::confused:
-
on a simple window form, there is a small panel, along with button and groupbox inside the panel. When I change the main window form color (i.e. this.BackColor = Color.Red) and the main form does turn red, and also the panel and groupbox were also changed to red. HUH? I just wanted the main form background color to be red, while the inside of the panel (and the panel itself) to remain unchanged. How do I do that? I tried goggling and turns out no luck. HELP!:confused::confused::confused::confused:
because the
backcolor
properties for the panel and groupbox were not initialised. If you set their backcolors first then change the forms backcolor they will not change. :-D -
because the
backcolor
properties for the panel and groupbox were not initialised. If you set their backcolors first then change the forms backcolor they will not change. :-D -
hmm interesting... thanks and tried it and does work. I have not realized this. Thanks a heap! :thumbsup: :-D
FYI The BackColor property, along with several others, is what is called an Ambient Property. This means that it gets its value from its parent control if it has not been changed first. Have a Google for ambient properties c# to get more details.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
on a simple window form, there is a small panel, along with button and groupbox inside the panel. When I change the main window form color (i.e. this.BackColor = Color.Red) and the main form does turn red, and also the panel and groupbox were also changed to red. HUH? I just wanted the main form background color to be red, while the inside of the panel (and the panel itself) to remain unchanged. How do I do that? I tried goggling and turns out no luck. HELP!:confused::confused::confused::confused:
Well if you want that I can give you little source code wish that help you : I give this code here in vb 2005 it's almost same in c# . dont know where you want to use visual basic or c# Private Sub lblbgcl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblbgcl.Click Dim mybackcolor As New ColorDialog() If mybackcolor.ShowDialog() = Windows.Forms.DialogResult.OK Then Me.BackColor = mybackcolor.Color Me.MenuStrip1.BackColor = nothing '' Write here what you want Me.Groupbox1.backcolor=nothing End If End Sub