无法更改Tab控件的背景 [英] Cannot change background on Tab control

查看:80
本文介绍了无法更改Tab控件的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改选项卡的整体背景颜色

控件(不在每个选项卡上)。


我试过Tabcontrol1.Backcolor = System .Drawing.Color.Blue

但这不起作用。

谢谢

mikl

解决方案

*" mikl" <一个******* @ discussions.microsoft.com> scripsit:

如何更改选项卡
控件的整体背景颜色(不在每个单独的选项卡上)。

我试过Tabcontrol1.Backcolor = System。 Drawing.Color.Blue
但这不起作用。




< http://www.onteorasoftware.com/VisualBasic.aspx#AnsTQ1>


-

Herfried K. Wagner

MVP·VB Classic,VB.NET

< ; http://www.mvps.org/dotnet>


< http://www.plig.net/nnq/nquote.html>


你必须覆盖控件的BackColor属性。

将以下类添加到项目中


**** *****************


公共类ColorTabCtrl

继承System.Windows.Forms.TabControl

''ColorTabCtrl

私有ColorVarBackColor为Color =

System.Drawing.SystemColors.ActiveBorder

覆盖属性BackColor()作为颜色

''设置检索房产价值的方法。

获取

返回ColorVarBackColor

结束获取

''设置设置属性值的方法。

设置(ByVal值为颜色)

ColorVarBackColor = Value

结束套件

结束物业

结束班级


***********


要使用ColorTabCtrl,请转到TabControl的Form1声明部分。通过

默认它应该有


Friend WithEvents TabControl1 As System.Windows.Forms.TabControl


替换以上代码如下


Friend WithEvents TabControl1 As ColorTabCtrl


*************


默认情况下,Sub InitializeComponent()有以下代码


Me.TabControl1 = New System.Windows.Forms.TabControl()


用以下行替换上面的代码


Me.TabControl1 = New ColorTabCtrl()


****** ***** $


为TabControl设置BackColor


Me.TabControl1.BackColor = System.Drawing.Color.Blue


*****************************


祝你好运!


Shawn Shelton

mikl写道:

如何更改整体背景颜色一个选项卡
控件(不在每个单独的选项卡上)。

我试过Tabcontrol1.Backcolor = S ystem.Drawing.Color.Blue
但这不起作用。

谢谢
mikl



这些都没有奏效。我想更改

整个背景颜色,而不仅仅是标签(见下文)


这些仍然没有解决问题。


还有其他什么建议吗?


谢谢,


mikl

---- - 原始消息-----
如何更改选项卡
控件的整体背景颜色(不在每个选项卡上)。

我试过Tabcontrol1.Backcolor = System.Drawing.Color.Blue
但这不起作用。

谢谢
mikl



How do you change the overall background color for a tab
control (not on each individual tab).

I tried Tabcontrol1.Backcolor = System.Drawing.Color.Blue
but this did not work.
Thanks
mikl

解决方案

* "mikl" <an*******@discussions.microsoft.com> scripsit:

How do you change the overall background color for a tab
control (not on each individual tab).

I tried Tabcontrol1.Backcolor = System.Drawing.Color.Blue
but this did not work.



<http://www.onteorasoftware.com/VisualBasic.aspx#AnsTQ1>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>


You have to override the BackColor property of the control.
Add the following class to your project

*********************

Public Class ColorTabCtrl
Inherits System.Windows.Forms.TabControl
''ColorTabCtrl
Private ColorVarBackColor As Color =
System.Drawing.SystemColors.ActiveBorder
Overrides Property BackColor() As Color
''Sets the method for retrieving the value of your property.
Get
Return ColorVarBackColor
End Get
''Sets the method for setting the value of your property.
Set(ByVal Value As Color)
ColorVarBackColor = Value
End Set
End Property
End Class

***********

To use ColorTabCtrl, go to Form1 declaration section for TabControl. By
default it should have

Friend WithEvents TabControl1 As System.Windows.Forms.TabControl

replace above code with following line

Friend WithEvents TabControl1 As ColorTabCtrl

*************

By default, Sub InitializeComponent() have follwoing code

Me.TabControl1 = New System.Windows.Forms.TabControl()

replace above code with following line

Me.TabControl1 = New ColorTabCtrl()

*************

Set BackColor for TabControl

Me.TabControl1.BackColor = System.Drawing.Color.Blue

*****************************

Good Luck!

Shawn Shelton
mikl wrote:

How do you change the overall background color for a tab
control (not on each individual tab).

I tried Tabcontrol1.Backcolor = System.Drawing.Color.Blue
but this did not work.
Thanks
mikl




Neither of these worked well at all. I want to change the
entire background color, not just the tabs (SEE BELOW)

These still do not address the issue.

Any other Suggestions?

thanks,

mikl

-----Original Message-----
How do you change the overall background color for a tab
control (not on each individual tab).

I tried Tabcontrol1.Backcolor = System.Drawing.Color.Blue
but this did not work.
Thanks
mikl
.



这篇关于无法更改Tab控件的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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