gpt4 book ai didi

c# - 透明选项卡控件显示为白色

转载 作者:行者123 更新时间:2023-12-02 22:12:33 26 4
gpt4 key购买 nike

无论如何,我在使用选项卡控件时遇到了一些困难。当我将一个新的选项卡控件拖到窗体上时,它显示为白色,而不是我期望的灰色(系统颜色)。

当我查看属性时,它的颜色设置为网络透明。好的,那么它应该是透明的(它不会让它后面的任何东西显示出来)。将选项卡控件的背景颜色手动设置回系统灰色,但顶部的选项卡仍显示为白色。我假设我也可以以某种方式改变它们的颜色,但我很快就进入了从默认值改变这么多值的领域,我显然错过了一些类型的领域。我尽可能地搜索了“透明选项卡控件绘制白色”的每个变体,虽然我发现了一些与 Windows 配置文件有关的东西,但这似乎主要局限于使用你在访问中访问的 vb 访问 2003。

我正在寻找关于以下方面的任何解释:

  • 我需要做什么才能正确使用选项卡控件的透明度
  • 我误解了选项卡控件中透明度的目的
  • 如何轻松地将选项卡控件相应部分的所有颜色更改为不透明。

我正在查看 MCTS 的 Windows 窗体,因此请不要给出“您应该使用 X 代替”类型的答案。

最佳答案

不,变白当然是正常的。启用视觉样式后,TabControl 和 TabPage 将使用主题颜色呈现。因此,在具有标准 Windows 主题的机器上,标签页会变成白色。

是的,Transparent默认的BackColor很不一般。您肯定永远不会获得真正的透明度,除非您将 TabControl 的背景视为透明度。逻辑非常复杂,我不想解释它,而是直接粘贴 MSDN 解释:

The default value of the BackColor property is the value of the Control.DefaultBackColor property unless the UseVisualStyleBackColor and Application.RenderWithVisualStyles property values are both true and the Appearance property of the parent TabControl has a value of Normal, in which case the default value of the BackColor property is Transparent. Child controls that you place on the TabPage inherit the BackColor value by default, so this behavior causes the background of the child controls to render with the current visual style.

Changing the value of the BackColor property automatically sets the UseVisualStyleBackColor property to false. If you want the TabPage background to render using visual styles but you want the child controls to inherit a BackColor value that you specify, set the UseVisualStyleBackColor property after you set the BackColor property.

关于c# - 透明选项卡控件显示为白色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15012827/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com