chaging the color of the tabstrip in VB.net

jbajaj
jbajaj used Ask the Experts™
on
hello

I am usng tabcontrol in my application and having problem matching my tab color ( not tabpages) with my background color.
I made the tab color different from the tab pages color by using the following code. However I still see the grey between the tabs. I want to change the entire color of the tabstrip. Please help or give me a workaround asap

here is the code to have diff color between the tab and the tabpages

  Private Sub TabControl1_DrawItem(ByVal sender As Object, _
       ByVal e As System.Windows.Forms.DrawItemEventArgs) _
       Handles TabControl1.DrawItem


        Dim s As String = TabControl1.TabPages(e.Index).Text
        Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds)
        Dim sf As New StringFormat
        sf.Alignment = StringAlignment.Center
        sf.LineAlignment = StringAlignment.Center


        If CBool(e.State And DrawItemState.Selected) Then
            e.Graphics.FillRectangle(Brushes.Bisque, e.Bounds)
            e.Graphics.DrawString(s, e.Font, Brushes.Chocolate, r, sf)
        Else
            e.Graphics.FillRectangle(Brushes.Azure, e.Bounds)
            e.Graphics.DrawString(s, e.Font, Brushes.Blue, r, sf)
        End If


        sf.Dispose()


    End Sub

Thank you
jayesh
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior .Net Consultant
Top Expert 2016
Commented:

Author

Commented:
Hello

I tried my best to get the A Completely OwnerDraw TabControl. working but unable to do so ( sorry i have limited knowledge in VB). I already have the tabcontrol implemented .However I am unable to change the tab strip color.
I have been able to change the color of the tabs on clicking . I just want to change the color of the tabstrip

Can you please help me with it asap

Thank you

We've used this control in the past http://www.dotnetmagic.com/
You have full control over the colours etc ... otherwise to change the colours in the tab control you will need to use gdi :)
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
the link I have provided does that. Please try this control.

Author

Commented:
I used the control in http://dotnetrix.co.uk/tabcontrols.html

but then now my above code to change the color of tab on selecting it stops working

Please help
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
merge the 2 code together.

Author

Commented:
I am unable to do so, can you please help

Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
It might go to tomorrow

Author

Commented:
Yes, Please send me the merged code. I am having problems.

Thank you
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
which sample have you started with? I suppose you used "A Completely OwnerDraw TabControl". Can you tell me exactly what is not working for you?

have you seen the "TabControl using Custom TabPages." that seems to have (when we look at the image) a transparent background.
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
Have you seen TabControlEx on http://dotnetrix.co.uk/tabcontrols.html
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
I think I deserve the points.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial