【问题标题】:Tabcontrol, vb.net, tab button mouse over styleTabcontrol, vb.net, tab button mouse over style
【发布时间】:2011-11-22 22:39:37
【问题描述】:

我有一个带有 tabcontrol 的 vb.net windows 窗体项目。

有谁知道当您将鼠标悬停在标签页标题或“按钮”上时如何更改其样式?

我猜你可以改变颜色:

TabControl1.SelectedTab.BackColor = Color.Black

但不确定如何将鼠标悬停在悬停的选项卡标题/按钮上。

【问题讨论】:

    标签: vb.net styles tabcontrol mouseover


    【解决方案1】:

    如果你想改变标签页的颜色(即有标签内容的区域),很容易做到,如下图所示。

    但是,如果你想改变tab按钮,那么你需要将TabControl1 DrawMode设置为TabDrawMode.OwnerDrawFixed,然后处理DrawItem事件。

    Public Class Form1
    
    
          Private Sub TabControl1_MouseEnter(sender As System.Object, e As System.EventArgs) Handles TabControl1.MouseEnter
            TabControl1.SelectedTab.BackColor = Color.Black
          End Sub
    
          Private Sub TabControl1_MouseLeave(sender As System.Object, e As System.EventArgs) Handles TabControl1.MouseLeave
            TabControl1.SelectedTab.BackColor = DefaultBackColor
          End Sub
        End Class
    

    【讨论】:

    【解决方案2】:

    TabControl 内置了此功能的基本形式。尝试设置HotTrack = True。当您将鼠标悬停在选项卡上时,它将更改文本颜色。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-21
      • 2012-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多