WinForms 标签不想透明的原因是什么? [英] Reasons for why a WinForms label does not want to be transparent?

查看:18
本文介绍了WinForms 标签不想透明的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我不能将标签的背景色设置为透明?我以前做过,但现在就是不想……

Why can't I set the BackColor of a Label to Transparent? I have done it before, but now it just don't want to...

我创建了一个新的 UserControl,为其添加了一个进度条和一个标签.当我将标签的 BackColor 设置为透明时,它仍然是灰色的 =/为什么会这样?

I created a new UserControl, added a progressbar and a label to it. When I set the BackColor of the label to transparent it is still gray =/ Why is this?

我想要的是将标签放在进度条顶部,以便其文本在进度条中"...

What I wanted was to have the label on top of the progressbar so that its text was "in" the progressbar...

推荐答案

WinForms 并不真正支持透明控件,但您可以自己制作透明控件.在这里查看我的答案.

WinForms doesn't really support transparent controls, but you can make a transparent control yourself. See my answer here.

在您的情况下,您可能应该将进度条子类化并覆盖 OnPaint 方法以在进度条上绘制文本.

In your case you should probably subclass the progress bar and override the OnPaint method to draw a text on the progress bar.

这篇关于WinForms 标签不想透明的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆