PDA

Click to See Complete Forum and Search --> : TextBox woes... Scrolling and Color


Kosta
Nov 30th, 2002, 05:39 PM
Hello,

I'm hoping someone can help me out here...

If I "TextBox1.Enabled = False" so that text can not be typed or even selected, the ForeColor for that TextBox1 (the font color) is changed automatically to a sort of greyed-out bronze color. How can I keep the "TextBox.ForeColor = System.Drawing.Color.Black" regardless of wether or not the control is enabled. I'm guessing it has something to do with deriving my own CustomTextBoxClass, but an example would be really helpful.

Also, how would I scroll the text in TextBox1 from left to right and back again automatically, without showing any scrollbars, if the text is longer than the width of the TextBox? I'm looking for the same effect used in WinAmp when it's scrolling the song title back and forth.

Thanks!
Kosta

DevGrp
Nov 30th, 2002, 09:43 PM
Enable the textbox, then set the read only property to true.

Kosta
Nov 30th, 2002, 10:02 PM
If the TextBox is Enabled, but set to ReadOnly, you can still select the text, just not type in the box.

I'm trying to hide the fact that it's a TextBox. I don't want the user to even be able to select the text. The only way I can do this is to Disable the TextBox, but like I said above, then the font color is greyed.

Any other ways to do this? Thanks!

hellswraith
Nov 30th, 2002, 10:16 PM
Can't you then just use a label. If you don't want the user to edit it, but want them to see it, that is what the label is for.

If you need the textbox look and functionality sometimes, and the label functionality other times, you can do some trickery.

First, place the textbox on the form, then put a label right over top of it. Size the label to fit the white area inside the textbox. Now, make sure that the label and the textbox always have the same text in them, your going to have to code that part. Next, when you want the user to use it like a label, just show the label. When you want them to edit the text, hide the label. Just make sure that you set the label text the same as the textbox's text after the user changes it.

Probably not the most efficient way, but until someone else comes up with something besides building your own control, that is what I would do.

Kosta
Dec 1st, 2002, 12:46 AM
:o Okay, I'm retarded... How could I have overlooked a label ?!?!?

Thanks !

Athley
Dec 1st, 2002, 04:15 AM
If you use a plain label with borderstyle set to fixed 3D and set the backcolor to white, the look will be much like a textbox, and you wouldn't even need to have a texbox in the background.