我已经进行了几个小时的Google搜索,测试等工作,而我是从哪里开始的。 WinForms TabControl
很烂...有没有人提示或编写代码,因此当我选择TabPage
时,字体或颜色会更改吗?
我弄乱了draw命令,尽管确实起作用,但它会绘制边框/背景,因此它们看起来很旧/过时。
这基本上是一个简单的标签文本编辑器,当控件中的TextBox
更改时,我正在使用该标签,我可以用红色字体或仅将其粗体显示为TextBox
上的TabPage
]被修改。
我肯定对替代TabControl
持开放态度,只要它们是免费的,并带有VB.Net示例。
这在VB.Net 2008 Express中。
将选项卡控件的DrawMode设置为OwnerDrawFixed,并根据DrawItem事件自己绘制选项卡。
将TabControl绘制模式设置为OwnerDrawFixed,然后创建事件处理程序以绘制标签以响应DrawItem事件。例如
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
Dim tabctl As TabControl = DirectCast(sender, TabControl)
Dim g As Graphics = e.Graphics
Dim font As Font = tabctl.Font
Dim brush As New SolidBrush(Color.Black)
tabTextArea = RectangleF.op_Implicit(tabctl.GetTabRect(e.Index))
If tabctl.SelectedIndex = e.Index Then
font = New Font(font, FontStyle.Bold)
brush = New SolidBrush(Color.Red)
End If
g.DrawString(tabctl.TabPages(e.Index).Text, font, brush, tabTextArea)
End Sub