2011-12-07 4 views
2

어떻게 회색 부분을 흰색으로 변경할 수 있습니까? 내 tabcontrol 전체 흰 색으로 채워 넣고 싶습니다.탭 컨트롤 배경색 (VB.NET)을 변경하는 방법

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 기능에서이 문제를 넣어 :

enter image description here

지금까지 내가 한 일이 같다

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

답변

1

이 작업을 수행 할 재산이 없습니다. 그러나이 사이트에이

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

모든 컨트롤 같은 것을 사용하여 수는 MIT 라이선스에 따라 자유롭게 사용할 수 있습니다.

0

누군가가 해결책을 찾은 경우 지출하는 공정한 시간을 소비합니다. 주변에서 약간의 문제가있을 수 있습니다. 그러나 MSDN Ref에 따르면.

TabControl.BackColor 재산권

NET 프레임 워크 (현재 버전) 이 API는 제품 인프라를 지원하며 사용자 코드에서 직접 사용할 수 없습니다.

이 구성원은이 제어에 의미가 없습니다.

네임 스페이스 : System.Windows.Forms 어셈블리 : System.Windows.Forms ( 가 system.windows.forms.dll에서)

는 지금까지 내가 이해,이 사용자의 Windows 설정에서 조정할 수 있습니다. (Highlight Color)의 TabControl, 양식 및 기타 통제; 그렇지 않으면 MS는이 속성을 켜기 만하면됩니다.

관련 문제