469,291 Members | 1,767 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,291 developers. It's quick & easy.

Enable/Disable Labels

Tom
Hi:

When you disable a text box you get the "ghost effect" on the
associated label control. How can you mimic that same effect on a
label not associated with a text box?

Basically, the setup I have is:

lblControlName txtControl lblUnit

Where:
lblControlName is the title of the control (e.g., "Density")
txtControl is the value (e.g., 8.34)
lblUnit is the unit for the control (e.g., "lbs/gal")

For certain records I need to disable txtControl because I don't what
the user entering data. When I set enabled = false for txtControl,
lblControlName also goes to ghost. However, lblUnit doesn't and it
looks funny. How do I get it to mimic the ghost effect?

Thanks
Tom

Dec 20 '06 #1
4 9155
MLH
Faced with the same dilemma in the past, I have resorted to
setting the label's Foreground and Background properties to
the colors in which the 'grayed out' text boxes are displayed
in. I seem to remember launching a discusion on that topic
on this NG a good while back and that was the best that
turned up.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx
On 20 Dec 2006 08:59:25 -0800, "Tom" <rt*****@swbell.netwrote:
>Hi:

When you disable a text box you get the "ghost effect" on the
associated label control. How can you mimic that same effect on a
label not associated with a text box?

Basically, the setup I have is:

lblControlName txtControl lblUnit

Where:
lblControlName is the title of the control (e.g., "Density")
txtControl is the value (e.g., 8.34)
lblUnit is the unit for the control (e.g., "lbs/gal")

For certain records I need to disable txtControl because I don't what
the user entering data. When I set enabled = false for txtControl,
lblControlName also goes to ghost. However, lblUnit doesn't and it
looks funny. How do I get it to mimic the ghost effect?

Thanks
Tom
Dec 20 '06 #2
Tom, this isn't a very elegant solution, but it works: you can make one long
label that contains both the control name and the units, with a big gap in
the middle that you cover up with the textbox. If this long label is
associated with the textbox, the whole thing will grey out when you disable
the textbox.
-John

"Tom" <rt*****@swbell.netwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi:

When you disable a text box you get the "ghost effect" on the
associated label control. How can you mimic that same effect on a
label not associated with a text box?

Basically, the setup I have is:

lblControlName txtControl lblUnit

Where:
lblControlName is the title of the control (e.g., "Density")
txtControl is the value (e.g., 8.34)
lblUnit is the unit for the control (e.g., "lbs/gal")

For certain records I need to disable txtControl because I don't what
the user entering data. When I set enabled = false for txtControl,
lblControlName also goes to ghost. However, lblUnit doesn't and it
looks funny. How do I get it to mimic the ghost effect?

Thanks
Tom

Dec 20 '06 #3
Another approach is to associate the label with an unbound textbox.
Set the textbox width to 0, special effect to flat, border and
background to transparent, and tab stop to 'no'. The textbox will be
effectively hidden at that point and its associated label can be
'disabled' by disabling the textbox.

Bruce

Dec 20 '06 #4
Tom
Thanks to all 3 of you for your thoughts. It seems like there are a
few work arounds, but no elegant solutions. <sigh>.

Bruce - I think I like your solution the best, it seems to be the one
least likely to have unexpected problems crop up at a later date.

Tom
de***************@gmail.com wrote:
Another approach is to associate the label with an unbound textbox.
Set the textbox width to 0, special effect to flat, border and
background to transparent, and tab stop to 'no'. The textbox will be
effectively hidden at that point and its associated label can be
'disabled' by disabling the textbox.

Bruce
Dec 20 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Alphonse Giambrone | last post: by
reply views Thread by talal | last post: by
8 posts views Thread by rongchaua | last post: by
10 posts views Thread by viki1967 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.