Results 1 to 4 of 4
  1. #1
    -Jerry™'s Avatar
    Join Date
    Jun 2009
    Gender
    male
    Posts
    412
    Reputation
    15
    Thanks
    88
    My Mood
    Psychedelic

    Visual Basics Tab control color help.

    I am new to VB and trying to make my first GUI. Though the Tab control is annoying me, as the default background is grey. I read around and it is not possible to change without using a code.

    Code:
    Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
    
        'Firstly we'll define some parameters.
        Dim CurrentTab As TabPage = TabControl1.TabPages(e.Index)
        Dim ItemRect As Rectangle = TabControl1.GetTabRect(e.Index)
        Dim FillBrush As New SolidBrush(Color.Red)
        Dim TextBrush As New SolidBrush(Color.White)
        Dim sf As New StringFormat
        sf.Alignment = StringAlignment.Center
        sf.LineAlignment = StringAlignment.Center
    
        'If we are currently painting the Selected TabItem we'll 
        'change the brush colors and inflate the rectangle.
        If CBool(e.State And DrawItemState.Selected) Then
            FillBrush.Color = Color.White
            TextBrush.Color = Color.Red
            ItemRect.Inflate(2, 2)
        End If
    
        'Set up rotation for left and right aligned tabs
        If TabControl1.Alignment = TabAlignment.Left Or TabControl1.Alignment = TabAlignment.Right Then
            Dim RotateAngle As Single = 90
            If TabControl1.Alignment = TabAlignment.Left Then RotateAngle = 270
            Dim cp As New PointF(ItemRect.Left + (ItemRect.Width \ 2), ItemRect.Top + (ItemRect.Height \ 2))
            e.Graphics.TranslateTransform(cp.X, cp.Y)
            e.Graphics.RotateTransform(RotateAngle)
            ItemRect = New Rectangle(-(ItemRect.Height \ 2), -(ItemRect.Width \ 2), ItemRect.Height, ItemRect.Width)
        End If
    
        'Next we'll paint the TabItem with our Fill Brush
        e.Graphics.FillRectangle(FillBrush, ItemRect)
    
        'Now draw the text.
        e.Graphics.DrawString(CurrentTab.Text, e.Font, TextBrush, RectangleF.op_Implicit(ItemRect), sf)
    
        'Reset any Graphics rotation
        e.Graphics.ResetTransform()
    
        'Finally, we should Dispose of our brushes.
        FillBrush.Dispose()
        TextBrush.Dispose()
    
    End Sub
    I found this code (Credits to Mike Doherty)
    This code is what i need, but it hides the images i have. He says on his website, "I'll leave you the challenge of modifying the code to show an image. "

    Because, right now this code changes the default grey background to whatever colour you want, but at the sametime hides the Images.

    Does anyone know how to show the images and change the background colour?

    Thanks in advance.

    - Image of Before

    - With Mike's code
    Last edited by -Jerry™; 07-13-2010 at 04:29 PM.

  2. #2
    Samueldo's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    Meh
    Posts
    1,023
    Reputation
    29
    Thanks
    348
    My Mood
    Inspired
    I asked this too and no one replied

    I see you got your source from the same site I did.

    I'm not sure about the images, try Googling something like "vb.net ownerdrawfixed show image on tabs".
    Quote Originally Posted by Grim View Post
    glad to be an inspiration
    Minions rule. /endof

    InjectPlz Refresh - download v1.0 now!

  3. #3
    Threadstarter
    Dual-Keyboard Member
    -Jerry™'s Avatar
    Join Date
    Jun 2009
    Gender
    male
    Posts
    412
    Reputation
    15
    Thanks
    88
    My Mood
    Psychedelic
    Quote Originally Posted by Samueldo View Post
    I asked this too and no one replied

    I see you got your source from the same site I did.

    I'm not sure about the images, try Googling something like "vb.net ownerdrawfixed show image on tabs".
    Mate i think i found it

    Painting Your Own Tabs - Second Edition - CodeProject

    Trying out now.

    Edit: still doesn't work but does anyone know how to use the above?
    Last edited by -Jerry™; 07-13-2010 at 05:12 PM.

  4. #4
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by -Jerry™ View Post
    Mate i think i found it

    Painting Your Own Tabs - Second Edition - CodeProject

    Trying out now.

    Edit: still doesn't work but does anyone know how to use the above?
    Code Project source will work !! Try it carefully !!

Similar Threads

  1. [Help Request] Help me to a hack or injector visual basic c++
    By deniz617 in forum CrossFire Help
    Replies: 1
    Last Post: 08-14-2011, 08:58 AM
  2. [Source Code] Visual Basic 2010 Codes to help you
    By Snoopys in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 8
    Last Post: 07-16-2011, 04:42 AM
  3. Visual Basic 2008 SendKeys.Send() Help
    By User1 in forum Visual Basic Programming
    Replies: 1
    Last Post: 07-31-2009, 03:52 PM
  4. visual basics help or vb6
    By josephjboogie3 in forum Visual Basic Programming
    Replies: 2
    Last Post: 11-05-2007, 05:25 AM
  5. [Help] Atom API with Visual Basic 6.0 or .NET
    By Bull3t in forum Visual Basic Programming
    Replies: 5
    Last Post: 07-23-2006, 09:21 AM