gpt4 book ai didi

vb.net - 如何更改选项卡控件背景颜色 (VB.NET)

转载 作者:行者123 更新时间:2023-12-02 02:35:31 25 4
gpt4 key购买 nike

如何将灰色部分变成白色?我希望我的选项卡控件充满全白色。

enter image description here

到目前为止我所做的是这样的:

Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
Dim g As Graphics = e.Graphics
Dim tp As TabPage = TabControl1.TabPages(e.Index)
Dim br As Brush
Dim sf As New StringFormat

Dim r As New RectangleF(e.Bounds.X, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height - 2)

sf.Alignment = StringAlignment.Center

Dim strTitle As String = tp.Text

'If the current index is the Selected Index, change the color
If TabControl1.SelectedIndex = e.Index Then

'this is the background color of the tabpage header
br = New SolidBrush(Color.White) ' chnge to your choice
g.FillRectangle(br, e.Bounds)

'this is the foreground color of the text in the tab header
br = New SolidBrush(Color.Black) ' change to your choice
g.DrawString(strTitle, TabControl1.Font, br, r, sf)

Else

'these are the colors for the unselected tab pages
br = New SolidBrush(Color.White) ' Change this to your preference
g.FillRectangle(br, e.Bounds)
br = New SolidBrush(Color.Black)
g.DrawString(strTitle, TabControl1.Font, br, r, sf)

End If
End Sub

我也把它放在 PageLoad 函数中:

TabControl1.DrawMode = TabDrawMode.OwnerDrawFixed
For Each tg As TabPage In TabControl1.TabPages
tg.BackColor = Color.White
Next

最佳答案

没有属性可以执行此操作。然而,通过使用这样的东西是可能的

http://dotnetrix.co.uk/tabcontrol.htm

本网站上的所有控件均可在 MIT 许可下免费使用。

关于vb.net - 如何更改选项卡控件背景颜色 (VB.NET),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8412810/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com