Link to home
Start Free TrialLog in
Avatar of GebhartBob
GebhartBob

asked on

How to Avoid Dimming Un-Enabled Controls

    Our application has many read-only fields. We just set Enabled to False, and it works fine.
 
     Except ... and there is always and forever an "except" ... we prefer that the un-enabled fields not be dimmed. Check boxes are particularly obnoxious, with that ugly gray background in the check box.
 
     Is there a way to defeat this dimming?
ASKER CERTIFIED SOLUTION
Avatar of MacRena
MacRena
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

control out of their control? - man, I gotta start proofreading my posts :)
Avatar of srauda
srauda

Set Locked to True.
Disregard my post.
Why don't you just loop through the collection of controls on the form and set them to enabled or not based on the Tag or Name or db-value.
Like this:

Sub Test()
Dim ctl As Control

    For Each ctl In Me.Controls
        ctl.Enabled = (ctl.Tag = "1")
    Next ctl
   
    Set ctl = Nothing
End Sub

Here the control is disabled when it's tag != 1.

D'Mzzl!
RoverM

On the flip side, users have come to expect certain standards.  When a field is disabled, they will recognize it by its ugly appearance and know that they can't be bothered with such fields.

If you make disabled fields appear enabled, you'll eventually be getting support calls about these fields that refuse to let them enter information:

Cust:"I tried clicking on the checkbox but it wouldn't let me check it."
Supp:"Did you use the mouse?"
Cust:"Yes, and it wouldn't put the check inside it."
Supp:"Are you sure it was a checkbox?"
Cust:"Of course!  Do you think I'm stupid?"
Supp:"Which field was it?"
Cust:"The one called XXX."
Supp:"Oh, that field is disabled?"
Cust:"Then why does it look like I can check it?"
Supp:"Because that's how it was designed."
Cust:"Well, that's stupid."
Supp:"Well, that's what your boss asked for."
Cust:hang up..."stupid programmers"

And the legacy of disrespectful, arrogant programmers lives on...
LOL
Avatar of Brendt Hess
One 'sneaky' way is to embed the controls inside another control (a frame with border set to None is good), then set .enabled = False on the containing control.

Although the controls still look like they are enabled, disableing their container means that they can not be changed by the user.

Another possibility is to make 'imitation' controls - controls that look like the type of control you are looking for, but don't have any of its functionality..
Good one, hess.  I'd forgotten about that "feature" (items in disabled containers are inaccessible but don't inherit the disabled appearance.)
You shouldn't worry so much about appearance (btw, it looks cool to me :), the important thing is functionality.

Tip: If you have read-only textboxes, do not disable them.  Use:
    TextBox.BackColor = vbButtonFace
    TextBox.Locked = True
    TextBox.TabStop = False
Users can copy/scroll the contents of that textbox.
Avatar of GebhartBob

ASKER

    I hear this comment loud and clear, and agree with it 100%:
 
On the flip side, users have come to expect certain standards.  When a field is disabled, they will
recognize it by its ugly appearance and know that they can't be bothered with such fields.

If you make disabled fields appear enabled, you'll eventually be getting support calls about these fields
that refuse to let them enter information:
 
     Nevertheless, if management insists, ours but to do or die ...

     If I gotta do it (and I'll quote the above verbatim), then I like MacRena's technique. It's simple, so simple even I can't screw it up.
 
     Thanks, guys.
"if management insists"

Damned management--always making us look bad! ;)

yea!!! i got one !!! :)
Just don't show them how disabled menus look like...  ;-)
A happy Mac...... it that a Happy Meal ? LOL
LOL Mark!!!
that's where that name came from - back in the 70's there was a commercial for 'Big Mac Attack' and my soccer (american term for 'football') buddies christened me that because of my rather aggressive way of relieving the opponent of the ball!!!

sorry to chatter on in your question, GebhartBob - we'll take it to the lounge :)