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.
Re: Simulating a disabled textbox
There is a ReadOnly property on a textbox that stops people from editing it.
D
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.;)
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 :blush:
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 :p , 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.
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. :p
Good Luck! :wave:
D
Re: Simulating a disabled textbox
Sure....I think it will work using that method.
Thanks a lot dminder
PS: Tomorrow I'll tell you
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.
;)
Re: Simulating a disabled textbox
Ok!! I'll do it tomorrow. Thanks again, Atheist