Results 1 to 6 of 6

Thread: TextBox woes... Scrolling and Color

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    20

    TextBox woes... Scrolling and Color

    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

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Enable the textbox, then set the read only property to true.
    Dont gain the world and lose your soul

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    20
    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!

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    20
    Okay, I'm retarded... How could I have overlooked a label ?!?!?

    Thanks !

  6. #6
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width