We help IT Professionals succeed at work.

How to Avoid Dimming Un-Enabled Controls

GebhartBob
GebhartBob asked
on
    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?
Comment
Watch Question

Commented:

I usually leave the control enabled, then put code in the GotFocus event that sends focus back to the Screen.PreviousControl (and take it out of the TabOrder)

That keeps the control out of their control while leaving it looking good.

Commented:

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

Commented:
Set Locked to True.

Commented:
Disregard my post.

Commented:
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

Commented:
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...

Commented:
LOL
Brendt HessSenior DBA
CERTIFIED EXPERT

Commented:
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..

Commented:
Good one, hess.  I'd forgotten about that "feature" (items in disabled containers are inaccessible but don't inherit the disabled appearance.)

Commented:
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.

Author

Commented:
    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.

Commented:
"if management insists"

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

Commented:

yea!!! i got one !!! :)

Commented:
Just don't show them how disabled menus look like...  ;-)

Commented:
A happy Mac...... it that a Happy Meal ? LOL

Commented:
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 :)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.