Srikanth kannan

Hi,

In my application i need the forecolor of a textbox whose readonly property is true, to be changed to dimgray.I couldnt change the text color of the textbox when the textbox is in readonly.

Is there any way of doing it.

Kindly help.Thanks in advance.



Re: Windows Forms General How to change the text colour of the textbox when readonly property is true???

nobugz

This reliably drives UI designers up the wall. You can't do it with TextBox, just make it invisible and make a label with the same text visible.





Re: Windows Forms General How to change the text colour of the textbox when readonly property is true???

Gavin Jin - MSFT

Hi kannan

Try this code

Me.TextBox1.ForeColor = Color.Red

Me.TextBox1.BackColor = Color.White

Me.TextBox1.ReadOnly = True

Hope it helps.

Regards.






Re: Windows Forms General How to change the text colour of the textbox when readonly property is true???

Srikanth kannan

Hi Jin

I need the textbox backcolor as gray and forecolor as dimgray.I have set the enabled property and the readonly property of the textbox as true.As a result of it the text color has changed to dark gray(almost black).I need the text color as dimgray(just like how it will be when enabled property is set false)

Kindly give me a suggestion.





Re: Windows Forms General How to change the text colour of the textbox when readonly property is true???

Gavin Jin - MSFT

You can change another color,suck like lightgray.




Re: Windows Forms General How to change the text colour of the textbox when readonly property is true???

Srikanth kannan

There is no effect in changing the forecolor when readonly is true. Watever value i give to the forecolor property, the text color is always dark gray.



Re: Windows Forms General How to change the text colour of the textbox when readonly property is true???

nobugz

Gavin is not giving you good info. The colors for a ReadOnly textbox are fixed and can't be changed. As you found out. Swapping it with a label is a workaround.





Re: Windows Forms General How to change the text colour of the textbox when readonly property is true???

Gavin Jin - MSFT

But I do enable to change the textbox backcolor and forcolor in this way

Me.TextBox1.Text = "123456"
Me.TextBox1.ForeColor = Color.Gray
Me.TextBox1.BackColor = Color.DimGray
Me.TextBox1.ReadOnly = True






Re: Windows Forms General How to change the text colour of the textbox when readonly property is true???

Srikanth kannan

Gavin,

The code you mentioned is not working out. I think i have to go for a label.

Anyway thanks gavin and nobugz