开发者

Tabcontrol, vb.net, tab button mouse over style

开发者 https://www.devze.com 2023-04-06 13:55 出处:网络
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 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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消