• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

setting the backcolor for a disabled textbox

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?


1 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

MikeORTECAuthor Commented:
Worked just like I wanted it to.


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now