vba 将标签背景色更改为默认值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23780885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 03:11:55  来源:igfitidea点击:

Change Label BackColor to default

vbauserform

提问by Kjenos

I was wondering how i can change the Background Color of a label in a UserForm back to the default value? (Transparent or like the UserFormcolor)

我想知道如何将用户窗体中标签的背景颜色更改回默认值?(透明或像用户窗体颜色)

Info_Label.BackColor = xlTransparent

or

或者

Info_Label.BackColor = xlNone

doesn't work.

不起作用。

回答by Gareth

If you want the label to be transparent, you need to set the BackStyleproperty like so:

如果您希望标签透明,则需要BackStyle像这样设置属性:

'Transparent
Info_Label.BackStyle = 0

'Opaque
Info_Label.BackStyle = 1

Alternatively, to return the label BackColorto the default color:

或者,要将标签BackColor恢复为默认颜色:

Info_Label.BackColor = vbButtonFace

回答by Alex K.

The default colour is the enum value vbButtonFaceso:

默认颜色是枚举值,vbButtonFace因此:

Info_Label.BackColor = vbButtonFace

Or to match the current form:

或者匹配当前表单:

Info_Label.BackColor = me.BackColor