Results 1 to 8 of 8

Thread: Simulating a disabled textbox

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    49

    Simulating a disabled textbox

    It's incredible. As soon as I get out of a problem (thanks to members of this forum many times), I get into another.

    Now, I need to disable a multiline textbox, so no one could edit or even click on the textbox (of course they could click, but it wouldn't have any effect)

    My first option was to use the enabled property, but the problem is that if I do that, I can't change the font color, so it looks kind of wierd. I need the color to be black, but I don't know hoy can I change it.

    Does anyone know hoy to solve this problem?

    Thanks in advance.

  2. #2
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: Simulating a disabled textbox

    There is a ReadOnly property on a textbox that stops people from editing it.

    D
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Simulating a disabled textbox

    Also, a Label with AutoSize set to False, BorderStyle set to Fixed3D and BackColor set to White "kind of" looks like a textbox.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    49

    Re: Simulating a disabled textbox

    Wow!! Those were really quick answers...

    I think that I haven't explain the problem as good as I should. I didn't want to be boring with the first post, so I didn't tell the whole story.

    Now, that I see that your answers are perfect answers for what I asked, I'm going to explain more my situation so you can understand all the facts that affect my problem.

    I have made my own user control. It's made up of a multiline textbox (without scrollbar), and a customized scrollbar.

    The text that it's going to be in the textbox can't be edit (as we have said before), but the problem is that I don't want the user to use the keyword to go through the text, because I don't know how to synchronize his movements with the scrollbar. So I need that the user cannot set the "text cursor" (I don't know if this is a correct term).

    I think that's all

    So, now, reading your answers (I repeat that they were correct because I didn't explain it correctly) I see several problems.

    Quote Originally Posted by dminder
    There is a ReadOnly property on a textbox that stops people from editing it.
    Yes, I know this property, but although it disable to edit the post, it allows the user to set the "text cursor".

    I size the oportunity to ask: How can I edit a Readonly property? (sorry for my ignorance)

    Quote Originally Posted by Atheist
    Also, a Label with AutoSize set to False, BorderStyle set to Fixed3D and BackColor set to White "kind of" looks like a textbox.
    The problem with the label is that the text is multiline, so it looks a little bit difficult to use it. But... if there isn't another option, I think that this is a good solution. I think that I can paint with GDI all the text in a bufferimage, and then move it up and down so it would only appear on the label region....isn't it?

    Since I don't speak english very well and obviously I'm far from being a Visual Basic Master , I dont' know if all the things that I have written are only stupidities.

    I promise that I have tried to do it my best.

    Thanks in advance for your answers.
    Last edited by sagoga69; Jan 23rd, 2008 at 12:37 PM.

  5. #5
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: Simulating a disabled textbox

    Along with the ReadOnly property you can also in code grab the Click, DoubleClick Methods and reset the focus to another control (like a button). i.e.
    Code:
        Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.GotFocus, TextBox1.Click, TextBox1.DoubleClick
            Button1.Focus()
        End Sub
    Not sure if this helps or not.

    Good Luck!

    D
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    49

    Re: Simulating a disabled textbox

    Sure....I think it will work using that method.

    Thanks a lot dminder

    PS: Tomorrow I'll tell you

  7. #7
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Simulating a disabled textbox

    You should choose the Enter event rather than the GotFocus event.

    MSDN:
    The GotFocus and LostFocus events are low-level focus events that are tied to the WM_KILLFOCUS and WM_SETFOCUS Windows messages. Typically, the GotFocus and LostFocus events are only used when updating UICues or when writing custom controls. Instead the Enter and Leave events should be used for all controls except the Form class, which uses the Activated and Deactivate events.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  8. #8

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    49

    Re: Simulating a disabled textbox

    Ok!! I'll do it tomorrow. Thanks again, Atheist

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