Home All Groups Group Topic Archive Search About

How to stop disabled text boxes being greyed out

Author
27 Nov 2007 4:25 PM
John Austin
I have an app that displays about 20 items of data in text boxes. Very
occasionally I need to allow these to be used for data entry, but the bulk of
the time they are solely for information. They all sit in a GroupBox that is
normally disabled, but is enabled when data can be edited. The users complain
that when the GroupBox.Enabled=False, the greyed out text boxes are hard to
read. I would like to find a way to disable the GroupBox whilst leaving the
text boxes clearly visible.
--
John Austin

--
John Austin

Author
27 Nov 2007 5:26 PM
Terry
You might try setting each textbox's ReadOnly property to True, instead of
disabling them.  Then when you wanted to enable (make them non ReadOnly), you
could:

        For Each ctrl As Control In GroupBox1.Controls
            If TypeOf ctrl Is TextBox Then
                DirectCast(ctrl, TextBox).ReadOnly = False
            End If
        Next

--
Terry


Show quoteHide quote
"John Austin" wrote:

> I have an app that displays about 20 items of data in text boxes. Very
> occasionally I need to allow these to be used for data entry, but the bulk of
> the time they are solely for information. They all sit in a GroupBox that is
> normally disabled, but is enabled when data can be edited. The users complain
> that when the GroupBox.Enabled=False, the greyed out text boxes are hard to
> read. I would like to find a way to disable the GroupBox whilst leaving the
> text boxes clearly visible.
> --
> John Austin
>
> --
> John Austin
Author
27 Nov 2007 6:48 PM
John Austin
Yes, I do a similar thing to set the text boxes BackColor in
GroupBox1.EnabledChanged so that it is obvious to the user when they can and
can't type in the boxes. The thing I don't like about setting ReadOnly is
that if the user can get the cursor in the box, they then phone up and ask
why they can't type anything. I really want to make the Text Boxes look like
labels when they can't type in them, and like text boxes when they can.

Thanks for the suggestion.
--
John Austin


Show quoteHide quote
"Terry" wrote:

> You might try setting each textbox's ReadOnly property to True, instead of
> disabling them.  Then when you wanted to enable (make them non ReadOnly), you
> could:
>
>         For Each ctrl As Control In GroupBox1.Controls
>             If TypeOf ctrl Is TextBox Then
>                 DirectCast(ctrl, TextBox).ReadOnly = False
>             End If
>         Next
>
> --
> Terry
>
>
> "John Austin" wrote:
>
> > I have an app that displays about 20 items of data in text boxes. Very
> > occasionally I need to allow these to be used for data entry, but the bulk of
> > the time they are solely for information. They all sit in a GroupBox that is
> > normally disabled, but is enabled when data can be edited. The users complain
> > that when the GroupBox.Enabled=False, the greyed out text boxes are hard to
> > read. I would like to find a way to disable the GroupBox whilst leaving the
> > text boxes clearly visible.
> > --
> > John Austin
> >
> > --
> > John Austin
Author
27 Nov 2007 9:28 PM
Terry
Well, you could alwayws switch between labels and textboxes in code.  The
reason that a readonly textbox can be 'entered' is to allow the user to see
any text that may extend beyond the limits.  In you don't want them to enter
it when it is readonly add the following to each of the enter events. 

        If TextBox1.ReadOnly = True Then
            Me.SelectNextControl(TextBox1, True, True, True, True)
        End If


May be better to just use 'addhandler' here.

Private Sub MoveAlong(Byval sender....)
Me.SelectNextControl(Sender, True....)
End Sub

In any case, you get the idea.    Also, if you really want them to look like
labels, then when you set their ReadOnly property to true, also set their
border style to 'None'.  Then they will look exactly like labels and with the
above code, can't be 'entered'.

--
Terry


Show quoteHide quote
"John Austin" wrote:

> Yes, I do a similar thing to set the text boxes BackColor in
> GroupBox1.EnabledChanged so that it is obvious to the user when they can and
> can't type in the boxes. The thing I don't like about setting ReadOnly is
> that if the user can get the cursor in the box, they then phone up and ask
> why they can't type anything. I really want to make the Text Boxes look like
> labels when they can't type in them, and like text boxes when they can.
>
> Thanks for the suggestion.
> --
> John Austin
>
>
> "Terry" wrote:
>
> > You might try setting each textbox's ReadOnly property to True, instead of
> > disabling them.  Then when you wanted to enable (make them non ReadOnly), you
> > could:
> >
> >         For Each ctrl As Control In GroupBox1.Controls
> >             If TypeOf ctrl Is TextBox Then
> >                 DirectCast(ctrl, TextBox).ReadOnly = False
> >             End If
> >         Next
> >
> > --
> > Terry
> >
> >
> > "John Austin" wrote:
> >
> > > I have an app that displays about 20 items of data in text boxes. Very
> > > occasionally I need to allow these to be used for data entry, but the bulk of
> > > the time they are solely for information. They all sit in a GroupBox that is
> > > normally disabled, but is enabled when data can be edited. The users complain
> > > that when the GroupBox.Enabled=False, the greyed out text boxes are hard to
> > > read. I would like to find a way to disable the GroupBox whilst leaving the
> > > text boxes clearly visible.
> > > --
> > > John Austin
> > >
> > > --
> > > John Austin
Author
27 Nov 2007 6:13 PM
Trevor Benedict
John
Although it is possible to use the Readonly property to lock the contents of
a Texbox. As a user I would expect a normal looking textbox to be editable
only to find that it is not. You may want to work with your uses to see how
they feel about this. Sometimes could be quite frustrating unless you show
them some visual cue as to when it is disabled and when enabled for editing.

Regards,

Trevor Benedict
MCSD

Show quoteHide quote
"John Austin" <John.Austin@nospam.nospam> wrote in message
news:4DA49FEE-1BFC-4EFD-A202-5E898D9BEEFF@microsoft.com...
>I have an app that displays about 20 items of data in text boxes. Very
> occasionally I need to allow these to be used for data entry, but the bulk
> of
> the time they are solely for information. They all sit in a GroupBox that
> is
> normally disabled, but is enabled when data can be edited. The users
> complain
> that when the GroupBox.Enabled=False, the greyed out text boxes are hard
> to
> read. I would like to find a way to disable the GroupBox whilst leaving
> the
> text boxes clearly visible.
> --
> John Austin
>
> --
> John Austin
Author
27 Nov 2007 6:48 PM
John Austin
Our postings have crossed - I agree!
--
John Austin


Show quoteHide quote
"Trevor Benedict" wrote:

> John
> Although it is possible to use the Readonly property to lock the contents of
> a Texbox. As a user I would expect a normal looking textbox to be editable
> only to find that it is not. You may want to work with your uses to see how
> they feel about this. Sometimes could be quite frustrating unless you show
> them some visual cue as to when it is disabled and when enabled for editing.
>
> Regards,
>
> Trevor Benedict
> MCSD
>
> "John Austin" <John.Austin@nospam.nospam> wrote in message
> news:4DA49FEE-1BFC-4EFD-A202-5E898D9BEEFF@microsoft.com...
> >I have an app that displays about 20 items of data in text boxes. Very
> > occasionally I need to allow these to be used for data entry, but the bulk
> > of
> > the time they are solely for information. They all sit in a GroupBox that
> > is
> > normally disabled, but is enabled when data can be edited. The users
> > complain
> > that when the GroupBox.Enabled=False, the greyed out text boxes are hard
> > to
> > read. I would like to find a way to disable the GroupBox whilst leaving
> > the
> > text boxes clearly visible.
> > --
> > John Austin
> >
> > --
> > John Austin
>
>
>
Author
27 Nov 2007 6:59 PM
Terry
I agree, but a ReadOnly textbox is not normal looking.  It has a 'control'
color background.  Also, if you clue your users by changing the background
when they enter it, you can skip that for a readonly. 
--
Terry


Show quoteHide quote
"Trevor Benedict" wrote:

> John
> Although it is possible to use the Readonly property to lock the contents of
> a Texbox. As a user I would expect a normal looking textbox to be editable
> only to find that it is not. You may want to work with your uses to see how
> they feel about this. Sometimes could be quite frustrating unless you show
> them some visual cue as to when it is disabled and when enabled for editing.
>
> Regards,
>
> Trevor Benedict
> MCSD
>
> "John Austin" <John.Austin@nospam.nospam> wrote in message
> news:4DA49FEE-1BFC-4EFD-A202-5E898D9BEEFF@microsoft.com...
> >I have an app that displays about 20 items of data in text boxes. Very
> > occasionally I need to allow these to be used for data entry, but the bulk
> > of
> > the time they are solely for information. They all sit in a GroupBox that
> > is
> > normally disabled, but is enabled when data can be edited. The users
> > complain
> > that when the GroupBox.Enabled=False, the greyed out text boxes are hard
> > to
> > read. I would like to find a way to disable the GroupBox whilst leaving
> > the
> > text boxes clearly visible.
> > --
> > John Austin
> >
> > --
> > John Austin
>
>
>