回答編集履歴
1
追記
answer
CHANGED
@@ -1,1 +1,37 @@
|
|
1
|
-
タブコントロールのタブをオーナードローすれば、変更できますよ。
|
1
|
+
タブコントロールのタブをオーナードローすれば、変更できますよ。
|
2
|
+
```
|
3
|
+
Public Class Form1
|
4
|
+
|
5
|
+
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
6
|
+
'タブコントロールの描画モードをオーナードローに変更
|
7
|
+
TabControl1.DrawMode = TabDrawMode.OwnerDrawFixed
|
8
|
+
End Sub
|
9
|
+
|
10
|
+
Private Sub TabControl1_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
|
11
|
+
Dim backBrush As SolidBrush
|
12
|
+
Dim foreBrush As SolidBrush
|
13
|
+
Dim font As Font
|
14
|
+
|
15
|
+
'背景や文字色、フォントは自由に設定してください
|
16
|
+
|
17
|
+
If TabControl1.SelectedIndex = e.Index Then
|
18
|
+
backBrush = New SolidBrush(Color.Navy)
|
19
|
+
foreBrush = New SolidBrush(Color.White)
|
20
|
+
font = New Font("Arial Black", 11, FontStyle.Bold)
|
21
|
+
Else
|
22
|
+
backBrush = New SolidBrush(SystemColors.Control)
|
23
|
+
foreBrush = New SolidBrush(Color.Black)
|
24
|
+
font = New Font("Arial Black", 11, FontStyle.Regular)
|
25
|
+
End If
|
26
|
+
|
27
|
+
Dim format As StringFormat = New StringFormat()
|
28
|
+
Dim rect As RectangleF = New RectangleF(e.Bounds.X, e.Bounds.Y + 6, e.Bounds.Width, e.Bounds.Height)
|
29
|
+
format.Alignment = StringAlignment.Center
|
30
|
+
|
31
|
+
e.Graphics.FillRectangle(backBrush, e.Bounds)
|
32
|
+
e.Graphics.DrawString(TabControl1.TabPages(e.Index).Text, font, foreBrush, rect, format)
|
33
|
+
End Sub
|
34
|
+
End Class
|
35
|
+
|
36
|
+
|
37
|
+
```
|