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. C#:How to change the color of a disabled Combobox control?

C#:How to change the color of a disabled Combobox control?

Scheduled Pinned Locked Moved C#
csharpgraphicshelptutorialquestion
6 Posts 4 Posters 0 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.
  • K Offline
    K Offline
    kssknov
    wrote on last edited by
    #1

    hi help me how to change the color of a readonly textbox and a Disabled combobox contrl to look like a normal one. comboBox1.Enabled = false; comboBox1.BackColor = System.Drawing.Color.Yellow;

    senthil

    M V 2 Replies Last reply
    0
    • K kssknov

      hi help me how to change the color of a readonly textbox and a Disabled combobox contrl to look like a normal one. comboBox1.Enabled = false; comboBox1.BackColor = System.Drawing.Color.Yellow;

      senthil

      M Offline
      M Offline
      Mustafa Ismail Mustafa
      wrote on last edited by
      #2

      First of all, why? The point behind making a control appear disabled is to stop the users from interacting with it. Anyways. You can't do it directly. It will always be gray. However, you can create your own control that inherits from the combobox and you can change that any way you please. Post back if you need more help or vote if this answers your question.

      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook "There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib "Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"

      K 1 Reply Last reply
      0
      • M Mustafa Ismail Mustafa

        First of all, why? The point behind making a control appear disabled is to stop the users from interacting with it. Anyways. You can't do it directly. It will always be gray. However, you can create your own control that inherits from the combobox and you can change that any way you please. Post back if you need more help or vote if this answers your question.

        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook "There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib "Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"

        K Offline
        K Offline
        kssknov
        wrote on last edited by
        #3

        hi mustafa assalamu alaikum my need is even though its a disabled contrl it should look like normal. i am beginner , can u tell me in detail thanku ssk

        ssk

        D M 2 Replies Last reply
        0
        • K kssknov

          hi mustafa assalamu alaikum my need is even though its a disabled contrl it should look like normal. i am beginner , can u tell me in detail thanku ssk

          ssk

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          This[^] has a way of doing it at the bottom of the page. The code is VB but should be easy enough to translate to C#.

          1 Reply Last reply
          0
          • K kssknov

            hi mustafa assalamu alaikum my need is even though its a disabled contrl it should look like normal. i am beginner , can u tell me in detail thanku ssk

            ssk

            M Offline
            M Offline
            Mustafa Ismail Mustafa
            wrote on last edited by
            #5

            Wa Alaikum Al Salam This Walkthrough will cover how to create the inherited control. http://msdn2.microsoft.com/en-us/library/5h0k2e6x(VS.80).aspx[^] Then, you'll have to handle the OnEnabledChanged event in your inherited control and take it from there. What you'll need is to either maintain the look and feel of the control or make it so that it is read only. [edit] Or read Davey's response, he gave you the whole she-bang!

            "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook "There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib "Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"

            1 Reply Last reply
            0
            • K kssknov

              hi help me how to change the color of a readonly textbox and a Disabled combobox contrl to look like a normal one. comboBox1.Enabled = false; comboBox1.BackColor = System.Drawing.Color.Yellow;

              senthil

              V Offline
              V Offline
              V 0
              wrote on last edited by
              #6

              This is a guess, but I think you can do it by overriding the OnPaint method.

              V.
              Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

              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