By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,693 Members | 1,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,693 IT Pros & Developers. It's quick & easy.

?disable txtbox without graying out font?

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
13 Replies

P: n/a
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.
-----Original Message-----
Hello,

So I would like to disable a textbox on a vb.net form
without the text getting grayed out. In vb6 I could placea textbox control on a frame control and disable the frameleaving 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
.

Nov 20 '05 #2

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:26****************************@phx.gbl...
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

Nov 20 '05 #3

P: n/a

? "Rich" <an*******@discussions.microsoft.com> ?????? ??? ??????
news:26****************************@phx.gbl...
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.
Nov 20 '05 #4

P: n/a
* "Rich" <an*******@discussions.microsoft.com> scripsit:
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.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #5

P: n/a
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.

-----Original Message-----
Hello,

So I would like to disable a textbox on a vb.net form
without the text getting grayed out. In vb6 I could placea textbox control on a frame control and disable the frameleaving 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
.

Nov 20 '05 #6

P: n/a
Use this in conjunction with setting the ReadOnly property to true:

attributes.add("style","cursor:normal")

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:28****************************@phx.gbl...
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.

-----Original Message-----
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
.

Nov 20 '05 #7

P: n/a
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.
"George L." <Ar*******@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...

? "Rich" <an*******@discussions.microsoft.com> ?????? ??? ??????
news:26****************************@phx.gbl...
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.

Nov 20 '05 #8

P: n/a
Why would the backcolor need to be reset? Setting to ReadOnly to true does
not change any of the colors.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c1*************@ID-208219.news.uni-berlin.de...
* "Rich" <an*******@discussions.microsoft.com> scripsit:
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.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>

Nov 20 '05 #9

P: n/a
* "Scott M." <s-***@BADSPAMsnet.net> scripsit:
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.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #10

P: n/a
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.

-----Original Message-----
Use this in conjunction with setting the ReadOnly property to true:
attributes.add("style","cursor:normal")

"Rich" <an*******@discussions.microsoft.com> wrote in messagenews:28****************************@phx.gbl...
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.

>-----Original Message-----
>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
>.
>

.

Nov 20 '05 #11

P: n/a
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.

-----Original Message-----
Use this in conjunction with setting the ReadOnly property to true:
attributes.add("style","cursor:normal")

"Rich" <an*******@discussions.microsoft.com> wrote in messagenews:28****************************@phx.gbl...
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.

>-----Original Message-----
>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
>.
>

.

Nov 20 '05 #12

P: n/a
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.
"Rich" <an*******@discussions.microsoft.com> wrote in message
news:29****************************@phx.gbl...
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.

-----Original Message-----
Use this in conjunction with setting the ReadOnly

property to true:

attributes.add("style","cursor:normal")

"Rich" <an*******@discussions.microsoft.com> wrote in

message
news:28****************************@phx.gbl...
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.
>-----Original Message-----
>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
>.
>

.

Nov 20 '05 #13

P: n/a
This works for me:

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

TextBox1.ReadOnly = True

TextBox1.BackColor = Color.White

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:29****************************@phx.gbl...
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.

-----Original Message-----
Use this in conjunction with setting the ReadOnly

property to true:

attributes.add("style","cursor:normal")

"Rich" <an*******@discussions.microsoft.com> wrote in

message
news:28****************************@phx.gbl...
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.
>-----Original Message-----
>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
>.
>

.

Nov 20 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.