如何更改选项卡控件背景色(VB.NET)
如何将灰色部分改为白色? 我想要我的tabcontrol填充全白色 到目前为止,我所做的是这样的:如何更改选项卡控件背景色(VB.NET),vb.net,Vb.net,如何将灰色部分改为白色? 我想要我的tabcontrol填充全白色 到目前为止,我所做的是这样的: Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem Dim g As Graphics = e.Graphics Dim tp As TabPage = Tab
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
Dim g As Graphics = e.Graphics
Dim tp As TabPage = TabControl1.TabPages(e.Index)
Dim br As Brush
Dim sf As New StringFormat
Dim r As New RectangleF(e.Bounds.X, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height - 2)
sf.Alignment = StringAlignment.Center
Dim strTitle As String = tp.Text
'If the current index is the Selected Index, change the color
If TabControl1.SelectedIndex = e.Index Then
'this is the background color of the tabpage header
br = New SolidBrush(Color.White) ' chnge to your choice
g.FillRectangle(br, e.Bounds)
'this is the foreground color of the text in the tab header
br = New SolidBrush(Color.Black) ' change to your choice
g.DrawString(strTitle, TabControl1.Font, br, r, sf)
Else
'these are the colors for the unselected tab pages
br = New SolidBrush(Color.White) ' Change this to your preference
g.FillRectangle(br, e.Bounds)
br = New SolidBrush(Color.Black)
g.DrawString(strTitle, TabControl1.Font, br, r, sf)
End If
End Sub
我还把它放在PageLoad函数中:
TabControl1.DrawMode = TabDrawMode.OwnerDrawFixed
For Each tg As TabPage In TabControl1.TabPages
tg.BackColor = Color.White
Next
没有这样做的属性。然而,使用这样的东西是可能的
本网站上的所有控件均在麻省理工学院许可下免费提供 如果有人找到了解决方案,就花合理的时间进行研究;可能有一些工作要做。但据报道 TabControl.BackColor属性 NET Framework(当前版本)此API支持该产品 基础架构,不打算直接从代码中使用。 此成员对此控件没有意义 命名空间:System.Windows.Forms程序集:System.Windows.Forms(在 System.Windows.Forms.dll)
据我所知,这是从用户的窗口设置调整。
选项卡控件
、窗体和其他控件的(高亮显示颜色
);否则MS可以简单地打开此属性。我做了一个技巧来解决这个问题,我在灰色部分加上一个白色标签,结果如下: