Solved

chaging the color of the tabstrip in VB.net

Posted on 2006-10-19
14
459 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:jbajaj
  • 8
  • 4
14 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 17770853
0
 

Author Comment

by:jbajaj
ID: 17771929
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
0
 
LVL 10

Expert Comment

by:Kinger247
ID: 17772830

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 :)
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 17773131
the link I have provided does that. Please try this control.
0
 

Author Comment

by:jbajaj
ID: 17787287
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
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 17787368
merge the 2 code together.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:jbajaj
ID: 17787375
I am unable to do so, can you please help

0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 17787398
It might go to tomorrow
0
 

Author Comment

by:jbajaj
ID: 17790199
Yes, Please send me the merged code. I am having problems.

Thank you
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 17795718
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.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 17795732
Have you seen TabControlEx on http://dotnetrix.co.uk/tabcontrols.html
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 17795740
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 17974741
I think I deserve the points.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now