具有当前标签页三角形的TabControl

时间:2018-09-13 09:24:58

标签: .net vb.net winforms drawing2d

我需要修改我在网上找到的tabcontrol,如果我更改项目高度,则三叉戟不能正确调整

enter image description here

执行绘图的代码是

G.SmoothingMode = SmoothingMode.HighQuality
                Dim p() As Point = {New Point(ItemSize.Height - 3, GetTabRect(i).Location.Y + 20), _
                           New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 14), _
                           New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 28)}
     G.FillPolygon(Brushes.White, p)
     G.DrawPolygon(New Pen(Color.FromArgb(170, 187, 204)), p)

我对New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 14)行进行了调整,但没有成功。

如果调整大小(例如说3点),我需要一个更大的三角形,但该三角形应位于Tabpage矩形的中心。

任何想法

1 个答案:

答案 0 :(得分:1)

经过进一步修补后,我能够找到解决方案

 Dim hlf As Integer = GetTabRect(i).Height \ 2
G.SmoothingMode = SmoothingMode.HighQuality
            Dim p() As Point = {New Point(ItemSize.Height - 6, GetTabRect(i).Location.Y + hlf), _
      New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + hlf - 7), _
      New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + hlf + 7)}