在不自定义重绘字符串的情况下设置 Winforms Tabpage 字体颜色
Set Winforms Tabpage Font Color without Custom Redrawing of String
有没有办法在 Winform 上指定 TabPage 的字体颜色?
我期待的是
tabControl1.TabPages["MyTab"].Font.Color = Color.Blue;
什么的?
有没有办法在 Winform 上指定 TabPage
的字体颜色? 没有,没有绘制它。
你要找的属性确实存在..:[=16=]
tabControl1.TabPages["MyTab"].ForeColor = Color.Blue;
..但它没有达到您的期望:TabPage.ForeColor only sets the color for controls that are nested in the tabpage. (Ambient property)
您在顶部看到的文本是 Tab
控件的一部分,颜色、字体和背景色仅通过 Tab
控件控制。
所以,是的,您需要编写 DrawItem
事件代码,您可以在其中访问每个标签页的属性。
有没有办法在 Winform 上指定 TabPage 的字体颜色?
我期待的是
tabControl1.TabPages["MyTab"].Font.Color = Color.Blue;
什么的?
有没有办法在 Winform 上指定 TabPage
的字体颜色? 没有,没有绘制它。
你要找的属性确实存在..:[=16=]
tabControl1.TabPages["MyTab"].ForeColor = Color.Blue;
..但它没有达到您的期望:TabPage.ForeColor only sets the color for controls that are nested in the tabpage. (Ambient property)
您在顶部看到的文本是 Tab
控件的一部分,颜色、字体和背景色仅通过 Tab
控件控制。
所以,是的,您需要编写 DrawItem
事件代码,您可以在其中访问每个标签页的属性。