Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. BackColor issue with main form and the controls

BackColor issue with main form and the controls

Scheduled Pinned Locked Moved C#
helpquestion
5 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Blubbo
    wrote on last edited by
    #1

    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:

    B J 2 Replies Last reply
    0
    • B Blubbo

      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:

      B Offline
      B Offline
      buachaill cliste
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • B buachaill cliste

        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

        B Offline
        B Offline
        Blubbo
        wrote on last edited by
        #3

        hmm interesting... thanks and tried it and does work. I have not realized this. Thanks a heap! :thumbsup: :-D

        H 1 Reply Last reply
        0
        • B Blubbo

          hmm interesting... thanks and tried it and does work. I have not realized this. Thanks a heap! :thumbsup: :-D

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          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.”

          1 Reply Last reply
          0
          • B Blubbo

            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:

            J Offline
            J Offline
            Jabbar_espania
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups