View Full Version : Change Color of Text Inside Text Box


crhodus
05-23-2001, 07:16 AM
What property will change the color of the text inside a disabled Text Box? I am wanting to change the color from grey to black so that it is more readable.

axa
05-23-2001, 07:55 AM
crhodus,

unfortunatly you cannot directly do this. you can however use a work around where by you use the 'Locked' property of the text box instead of the 'Enabled' property. Setting Locked=true will prevent changes to the value in the same way as Enabled=false, but you still have formatting control over the text box. So you could then set the Background color to a suitable colour to indicate whether the textbox is locked or not.

You could use a function like the one below to simplify the use of this method:

------------------------------------------

Function DisableTextBox(txt As TextBox, blnLocked As Boolean)
    If blnLocked = True Then
        txt.Locked = True
        txt.BackColor = vbButtonFace '--standard control gray
    Else
        txt.Locked = False
        txt.BackColor = vbWindowBackground
    End If
End Function

--------------------------------------------

This function requires you to pass it the reference to the relevant textbox control, and to indicate whether it should be locked or unlocked:

DisableTextBox txtMyTextbox, True

will lock txtMyTextBox

Hope that helps

axa