change colour of disabled textbox text

B

Basil

Hiya,

I have created a userform. There are 2 option buttons at the top - if they
select one, it will automatically diable all the textboxes on the userform.
If they select the other, it enables all the textboxes.

The problem is that when the textboxes are disabled, the colour of the text
within them goes grey and makes it hard to read (I need the users to be able
to see the textbox contents very clearly, even when disabled).

Is there a way that I can stop the disabling of a textbox from greying all
the textbox contents? Ideally I would like the content to go red, but staying
with the black would be fine.

Thanks,

Basil
 
D

Doug Glancy

Basil,

I think this is the preferred alternative. I was just reading about this in
Professional Excel Development the other day, don't know if I've got it
exactly right, though. It locks the textbox so can't be changed. One
benefit is that the user can still cut and paste the text in the textbox to
another locaiton, if needed. I changed the backcolor to the same color as
the buttons, so it indicates that you can't change it.:

Private Sub CommandButton1_Click()
Me.TextBox1.Locked = True
Me.TextBox1.BackColor = vbButtonFace
Me.TextBox1.ForeColor = vbRed
End Sub

hth,

Doug
 
B

Basil

Thanks mate - simple and sweet!!

Doug Glancy said:
Basil,

I think this is the preferred alternative. I was just reading about this in
Professional Excel Development the other day, don't know if I've got it
exactly right, though. It locks the textbox so can't be changed. One
benefit is that the user can still cut and paste the text in the textbox to
another locaiton, if needed. I changed the backcolor to the same color as
the buttons, so it indicates that you can't change it.:

Private Sub CommandButton1_Click()
Me.TextBox1.Locked = True
Me.TextBox1.BackColor = vbButtonFace
Me.TextBox1.ForeColor = vbRed
End Sub

hth,

Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top