Tabcontrol,vb.net,选项卡按钮鼠标悬停样式

发布于 2024-12-06 03:37:56 字数 222 浏览 1 评论 0原文

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

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

我想您可以通过以下方式更改颜色:

TabControl1.SelectedTab.BackColor = Color.Black

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

I have a vb.net windows forms project with a tabcontrol.

Anyone know how to change the style of the tabpage title or "button" when you hover over it with the pointer ?

I guess you can change the colours with:

TabControl1.SelectedTab.BackColor = Color.Black

But not sure how to hook up the mouseover to the hovered over tab title/button.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美人如玉 2024-12-13 03:37:56

如果您想更改选项卡页(即带有选项卡内容的区域)的颜色,很容易做到,如下所示。

但是,如果要更改选项卡按钮,则需要将 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

If you want to change color of the tab page (i.e. area with tab content), it is very easy to do as shown below.

However, if you want to change tab button, then you need to set TabControl1 DrawMode to TabDrawMode.OwnerDrawFixed and then handle DrawItem event.

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
浸婚纱 2024-12-13 03:37:56

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

The TabControl has a basic form of this functionality built in. Try setting HotTrack = True. When you mouseover the tab, it will change text colour.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文