?disable txtbox without graying out font?

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

Hello,

So I would like to disable a textbox on a vb.net form
without the text getting grayed out. In vb6 I could place
a textbox control on a frame control and disable the frame
leaving the textbox enabled and text/background were
intact but mouse cursor remained an arraw (as opposed to
an I for editable). I tried a Panel control on my .net
form since I could I guess there is no longer a frame
control (also tried a groupbox control). I disable these
container controls, but in the panel the textbox got
grayed out. With groupbox, the textbox was still
editable. Any suggestions appreciated how to disable
textbox without graying it out.

Thanks,
Rich
 
I just had a thought. A lable with a 3d border kinda
looks like a textbox. Is this the way .net does it now?
Just checking.
 
In VB 6.0, all you needed to do what changed the locked property to true
(not the enabled property, which caused the text to gray out).

In .NET, you just change the ReadOnly property to true.
 
* "Rich said:
So I would like to disable a textbox on a vb.net form
without the text getting grayed out. In vb6 I could place
a textbox control on a frame control and disable the frame
leaving the textbox enabled and text/background were
intact but mouse cursor remained an arraw (as opposed to
an I for editable). I tried a Panel control on my .net
form since I could I guess there is no longer a frame
control (also tried a groupbox control). I disable these
container controls, but in the panel the textbox got
grayed out. With groupbox, the textbox was still
editable. Any suggestions appreciated how to disable
textbox without graying it out.

Set the textbox's 'ReadOnly' property to 'True' and reset the backcolor.
 
Thank you all for your replies. I did check out the lable
with 3d border. That kinda looks like a textbox.

My goal is to disable the textbox control such that when
you pass your mouse over the control the pointer does not
change from an arrow to an I. Readonly still lets the
mousepointer change to an I. The closest thing I have
found so far is to use a rich textbox disabled with a
label inside. The only hassel here is setting the size of
the rich textbox and label to make it look like a regular
textbox.
 
Use this in conjunction with setting the ReadOnly property to true:

attributes.add("style","cursor:normal")
 
Setting a TextBox to disabled grays out the text color, not the background
color. Attempts to change the text color back to black are ignored.

See my other post for the textbox solution.
 
Why would the backcolor need to be reset? Setting to ReadOnly to true does
not change any of the colors.
 
* "Scott M. said:
Why would the backcolor need to be reset? Setting to ReadOnly to true does
not change any of the colors.

It changes the backcolor to control color on .NET 1.1, Windows XP
Professional, so I have to reset it.
 
Thanks for this suggestion. May I ask how you implement
this? I looked around the help files for attributes,
cursor but have not found a way to implement your
suggestion (although, it sound pretty cool). Here is what
I tried:

txt1.attributes... obviously did not work
txt1.ReadOnly(attributes...)=false

Thanks for your suggestion though.
 
OK. I found this:

txt1.Cursor = System.Windows.Forms.Cursors.Arrow

This works but I can still enter the textbox. My goal is
to be able to disable the textbox without having it gray
out. I'm sure there is a way to do this if it was doable
in VB6.
 
Ok, you didn't specify earlier that you were talking about a Windows Forms
app and not an ASP.NET app (2 different textboxes), but anyway just make the
textbox ReadOnly as well as what you have done below and you are all set.
 
This works for me:

TextBox1.Cursor = System.Windows.Forms.Cursors.Arrow

TextBox1.ReadOnly = True

TextBox1.BackColor = Color.White
 
Yes. The 3d label is one option. Just not exactly like a
textbox, but may have to do. The end users over my way
are so picky! (the big people)
 
? "Rich said:
Hello,

So I would like to disable a textbox on a vb.net form
without the text getting grayed out. In vb6 I could place
a textbox control on a frame control and disable the frame
leaving the textbox enabled and text/background were
intact but mouse cursor remained an arraw (as opposed to
an I for editable). I tried a Panel control on my .net
form since I could I guess there is no longer a frame
control (also tried a groupbox control). I disable these
container controls, but in the panel the textbox got
grayed out. With groupbox, the textbox was still
editable. Any suggestions appreciated how to disable
textbox without graying it out.

Thanks,
Rich

Hi Rich!
After you set the 'enabled' property of the textbox to false
you can change the backcolor to web->white. You can always use a simple
label with white backcolor & Fixed3D BorderStyle.
 
Back
Top