Change TextBox Color

  • Thread starter Thread starter Andreas Schulz
  • Start date Start date
A

Andreas Schulz

Hi,

I have a TextBox with attribute ReadOnly set to true. As usual the
textbox color turn grey. Is it somehow possible to change that
behaviour? I want the color white instead. Using the ForeColor and
BackColor property does not change the textbox' color.

Thanks

Andreas
 
Unfortunately the ForeColor and BackColor properties are not working with
the current version of the .NET CF. If your TextBox contains ReadOnly
information all the time and if you can live with a different background
color only you could change your TextBox to a Label and add that Label to a
Panel. Then give the Panel the desired background color. If you dynamically
switch from ReadOnly to ReadWrite you can still use this scenario. Create a
hidden Panel + label inside it. When you switch the textbox to ReadOnly copy
its contents to the hidden label and make the Panel visible.
 
I have been struggling, trying to get the Label BackColor to change and
hoped the Service Pack 2 would finally let me do that. Since I can't have
that - I now see that backcolor by stealth is the answer. Maarten, you are
a god.


Thanks,

Cindy Cruciger
(e-mail address removed)

Miami Herald Publishing Company
 
Unfortunately the ForeColor and BackColor properties are not working with
the current version of the .NET CF. If your TextBox contains ReadOnly
information all the time and if you can live with a different background
color only you could change your TextBox to a Label and add that Label to a
Panel. Then give the Panel the desired background color. If you dynamically
switch from ReadOnly to ReadWrite you can still use this scenario. Create a
hidden Panel + label inside it. When you switch the textbox to ReadOnly copy
its contents to the hidden label and make the Panel visible.

Thanks Maarten,

your idea sounds good. But unfortunately it must be possible to scroll.
I do not change from read only to read/write. So I think I have to live
with the current textbox behaviour. Thanks a lot.

Andreas
 
Andreas,

you can try to just give the focus back if the textbox gets the focus.
It's not a nice solution, but it works for me. Especially you can still
scroll the textbox. On GetFocus just put the focus back to the form.

Christoph
 
Back
Top