setting the backcolor for a disabled textbox

Posted on 2005-05-07
Last Modified: 2012-05-05
I have been working on trying to set the color of a disabled textbox.  You can see some different things that I have tried.  It seems that if I use the "vbColor" property that I can get the backcolor set to vbBlue, vbRed, etc., but if I try to use system colors, I wind up with white.  I thought that if I set the textbox control to enabled = false that vb would "grayout" the box, but it doesnt look like it...any assistance?

If optSealed.Value <> True Then
        dblNewActUnitsValue = dblNewActValue / dblOldMassOrVolUnit
        lblActConcUnitsLabel.Caption = "" & strActivityUnit & "/" & strOldMassOrVolUnit & ""
        txtMassOrVolume.ForeColor = Gray 'returns a white background
        txtMassOrVolume.Enabled = False
        txtUncPercOneSigMassOrVol.Enabled = False
        txtUncPercOneSigMassOrVol.ForeColor = NavajoWhite 'returns a white background
        txtRefActConc.Enabled = False
        txtRefActConc.BackColor = Silver 'returns a black background
        txtUncPercActConcOneSig.Enabled = False
        txtUncPercActConcOneSig.BackColor = Silver 'returns a blank background
        lblActConcUnitsLabel.Caption = "" & strActivityUnit & ""
    End If

is there a property that I can set that will gray out the box when it is disabled to show that you cannot type a number in the box?


Question by:MikeORTEC
    LVL 19

    Accepted Solution

    There is no property that will grey out the text box. You have to change the backcolor to grey, as in:

    txtUncPercActConcOneSig.Enabled = False
    txtUncPercActConcOneSig.BackColor = vbButtonFace


    Author Comment

    Worked just like I wanted it to.



    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now