Thanks for that,
But if you change the forms background colour the area without tabs on is
still grey, any more ideas?
Mike
"scorpion53061" <admin@nospamherekjmsolutions.com> wrote in message
news:%23LvOuUGsEHA.516@TK2MSFTNGP09.phx.gbl...[color=blue]
>
http://www.onteorasoftware.com/downl...tabcontrol.zip
>
>
> "Michael Turner" <fishing@m-turner.co.uk> wrote in message
> news:u4jW8IGsEHA.2636@TK2MSFTNGP09.phx.gbl:[color=green]
> > Hi
> >
> > I copied and pasted this code into my new project and nothing seems to
> > happen(yes I did remove the old code), any idea's I must be missing
> > something? Do you have a sample you have already created I could purhaps
> > look at?
> >
> > Mike.
> >
> > "scorpion53061" <admin@nospamherekjmsolutions.com> wrote in message
> > news:u8OtJ6FsEHA.1816@TK2MSFTNGP15.phx.gbl...[color=darkred]
> > > Private Sub tabControl1_DrawItem(ByVal sender As Object, ByVal e As
> > > DrawItemEventArgs)
> > >
> > > Dim tc As TabControl = CType(sender, TabControl)
> > >
> > > Dim tp As TabPage = tc.TabPages(e.index)
> > >
> > > Dim strTitle As String = tp.Text
> > >
> > > Dim g As Graphics = e.Graphics
> > >
> > > Dim theBrush As Brush = New SolidBrush(Me.ForeColor)
> > >
> > > Dim sf As StringFormat = New StringFormat
> > >
> > > sf.Alignment = StringAlignment.Center
> > >
> > > g.FillRectangle(New SolidBrush(tp.BackColor), e.Bounds)
> > > e.Graphics.DrawString(strTitle, e.Font, _
> > > New SolidBrush(e.ForeColor), Bounds.Left + _
> > > Me.Width, Bounds.Top)
> > >
> > >
> > > End Sub
> > >
> > > "Michael Turner" <fishing@m-turner.co.uk> wrote in message
> > > news:er0z17EsEHA.2264@TK2MSFTNGP10.phx.gbl:
> > > > Here it is,
> > > >
> > > > Public Class Form1
> > > >
> > > > Inherits System.Windows.Forms.Form
> > > >
> > > > #Region " Windows Form Designer generated code "
> > > >
> > > > Public Sub New()
> > > >
> > > > MyBase.New()
> > > >
> > > > 'This call is required by the Windows Form Designer.
> > > >
> > > > InitializeComponent()
> > > >
> > > > 'Add any initialization after the InitializeComponent() call
> > > >
> > > > End Sub
> > > >
> > > > 'Form overrides dispose to clean up the component list.
> > > >
> > > > Protected Overloads Overrides Sub Dispose(ByVal disposing As
> > > > Boolean)
> > > >
> > > > If disposing Then
> > > >
> > > > If Not (components Is Nothing) Then
> > > >
> > > > components.Dispose()
> > > >
> > > > End If
> > > >
> > > > End If
> > > >
> > > > MyBase.Dispose(disposing)
> > > >
> > > > End Sub
> > > >
> > > > 'Required by the Windows Form Designer
> > > >
> > > > Private components As System.ComponentModel.IContainer
> > > >
> > > > 'NOTE: The following procedure is required by the Windows Form
> > > > Designer
> > > >
> > > > 'It can be modified using the Windows Form Designer.
> > > >
> > > > 'Do not modify it using the code editor.
> > > >
> > > > Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
> > > >
> > > > Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
> > > >
> > > > Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
> > > >
> > > > Friend WithEvents TabPage3 As System.Windows.Forms.TabPage
> > > >
> > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > > > InitializeComponent()
> > > >
> > > > Me.TabControl1 = New System.Windows.Forms.TabControl
> > > >
> > > > Me.TabPage1 = New System.Windows.Forms.TabPage
> > > >
> > > > Me.TabPage2 = New System.Windows.Forms.TabPage
> > > >
> > > > Me.TabPage3 = New System.Windows.Forms.TabPage
> > > >
> > > > Me.TabControl1.SuspendLayout()
> > > >
> > > > Me.SuspendLayout()
> > > >
> > > > '
> > > >
> > > > 'TabControl1
> > > >
> > > > '
> > > >
> > > > Me.TabControl1.Controls.Add(Me.TabPage1)
> > > >
> > > > Me.TabControl1.Controls.Add(Me.TabPage2)
> > > >
> > > > Me.TabControl1.Controls.Add(Me.TabPage3)
> > > >
> > > > Me.TabControl1.DrawMode =
> > > > System.Windows.Forms.TabDrawMode.OwnerDrawFixed
> > > >
> > > > Me.TabControl1.Location = New System.Drawing.Point(40, 40)
> > > >
> > > > Me.TabControl1.Name = "TabControl1"
> > > >
> > > > Me.TabControl1.SelectedIndex = 0
> > > >
> > > > Me.TabControl1.Size = New System.Drawing.Size(328, 176)
> > > >
> > > > Me.TabControl1.TabIndex = 0
> > > >
> > > > '
> > > >
> > > > 'TabPage1
> > > >
> > > > '
> > > >
> > > > Me.TabPage1.BackColor = System.Drawing.SystemColors.ActiveCaption
> > > >
> > > > Me.TabPage1.Location = New System.Drawing.Point(4, 22)
> > > >
> > > > Me.TabPage1.Name = "TabPage1"
> > > >
> > > > Me.TabPage1.Size = New System.Drawing.Size(320, 150)
> > > >
> > > > Me.TabPage1.TabIndex = 0
> > > >
> > > > Me.TabPage1.Text = "TabPage1"
> > > >
> > > > '
> > > >
> > > > 'TabPage2
> > > >
> > > > '
> > > >
> > > > Me.TabPage2.Location = New System.Drawing.Point(4, 22)
> > > >
> > > > Me.TabPage2.Name = "TabPage2"
> > > >
> > > > Me.TabPage2.Size = New System.Drawing.Size(320, 150)
> > > >
> > > > Me.TabPage2.TabIndex = 1
> > > >
> > > > Me.TabPage2.Text = "TabPage2"
> > > >
> > > > '
> > > >
> > > > 'TabPage3
> > > >
> > > > '
> > > >
> > > > Me.TabPage3.Location = New System.Drawing.Point(4, 22)
> > > >
> > > > Me.TabPage3.Name = "TabPage3"
> > > >
> > > > Me.TabPage3.Size = New System.Drawing.Size(320, 150)
> > > >
> > > > Me.TabPage3.TabIndex = 2
> > > >
> > > > Me.TabPage3.Text = "TabPage3"
> > > >
> > > > '
> > > >
> > > > 'Form1
> > > >
> > > > '
> > > >
> > > > Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
> > > >
> > > > Me.BackColor = System.Drawing.SystemColors.ControlDark
> > > >
> > > > Me.ClientSize = New System.Drawing.Size(528, 437)
> > > >
> > > > Me.Controls.Add(Me.TabControl1)
> > > >
> > > > Me.Name = "Form1"
> > > >
> > > > Me.Text = "Form1"
> > > >
> > > > Me.TabControl1.ResumeLayout(False)
> > > >
> > > > Me.ResumeLayout(False)
> > > >
> > > > End Sub
> > > >
> > > > #End Region
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Private Sub tabControl1_DrawItem(ByVal sender As Object, ByVal e As
> > > > DrawItemEventArgs)
> > > >
> > > > Dim tc As TabControl = CType(sender, TabControl)
> > > >
> > > > Dim tp As TabPage = tc.TabPages(e.index)
> > > >
> > > > Dim strTitle As String = tp.Text
> > > >
> > > > Dim g As Graphics = e.Graphics
> > > >
> > > > Dim theBrush As Brush = New SolidBrush(Me.ForeColor)
> > > >
> > > > Dim sf As StringFormat = New StringFormat
> > > >
> > > > sf.Alignment = StringAlignment.Center
> > > >
> > > > g.FillRectangle(New SolidBrush(tp.BackColor), e.Bounds)
> > > >
> > > > g.DrawString(strTitle, tc.Font, theBrush, e.Bounds, sf)
> > > >
> > > > End Sub
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Private Sub Form1_Load(ByVal sender As Object, ByVal e As
> > > > System.EventArgs)
> > > > Handles MyBase.Load
> > > >
> > > > Me.TabControl1.DrawMode = TabDrawMode.OwnerDrawFixed
> > > >
> > > > End Sub
> > > >
> > > > End Class
> > > >
> > > >
> > > >
> > > >
> > > > "scorpion53061" <admin@nospamherekjmsolutions.com> wrote in message
> > > > news:egJHg3EsEHA.3288@TK2MSFTNGP12.phx.gbl...
> > > > > Post your code in your form or class exactly as you have it.
> > > > >
> > > > >
> > > > > "Michael Turner" <fishing@m-turner.co.uk> wrote in message
> > > > > news:unLSXzEsEHA.3964@TK2MSFTNGP10.phx.gbl:
> > > > > > Hi
> > > > > >
> > > > > > I just tried that and even tried copying your code and got the
> > > > > > following
> > > > > > error,
> > > > > > C:\Documents and Settings\Michael\My Documents\Visual Studio
> > > > > > Projects\WindowsApplication7\Form1.vb(106): Overload resolution
> > > > > > failed
> > > > > > because no accessible 'DrawString' can be called with these
> > > > > > arguments:
> > > > > > 'Public Sub DrawString(s As String, font As
> > > > > > System.Drawing.Font,
> > > > > > brush
> > > > > > As System.Drawing.Brush, layoutRectangle As
> > > > > > System.Drawing.RectangleF,
> > > > > > format As System.Drawing.StringFormat)': Value of type
> > > > > > 'System.Drawing.Rectangle' cannot be converted to
> > > > > > 'System.Drawing.RectangleF'.
> > > > > > 'Public Sub DrawString(s As String, font As
> > > > > > System.Drawing.Font,
> > > > > > brush
> > > > > > As System.Drawing.Brush, point As System.Drawing.PointF, format
> > > > > > As
> > > > > > System.Drawing.StringFormat)': Value of type
> > > > > > 'System.Drawing.Rectangle'
> > > > > > cannot be converted to 'System.Drawing.PointF'.
> > > > > > 'Public Sub DrawString(s As String, font As
> > > > > > System.Drawing.Font,
> > > > > > brush
> > > > > > As System.Drawing.Brush, x As Single, y As Single)': Value of
> > > > > > type
> > > > > > 'System.Drawing.Rectangle' cannot be converted to 'Single'.
> > > > > > 'Public Sub DrawString(s As String, font As
> > > > > > System.Drawing.Font,
> > > > > > brush
> > > > > > As System.Drawing.Brush, x As Single, y As Single)': Value of
> > > > > > type
> > > > > > 'System.Drawing.StringFormat' cannot be converted to 'Single'.
> > > > > >
> > > > > > And Ideas?
> > > > > >
> > > > > > Mike.
> > > > > >
> > > > > >
> > > > > > "scorpion53061" <admin@nospamherekjmsolutions.com> wrote in
> > > > > > message
> > > > > > news:OmSabrEsEHA.2588@TK2MSFTNGP12.phx.gbl...
> > > > > > > Set the tab control's DrawMode property to OwnerDrawFixed, and
> > > > > > > supply
> > > > > > > an
> > > > > > > event handler for the DrawItem event. In that event, Imports
> > > > > > > the
> > > > > > > event
> > > > > > > arg's
> > > > > > > Graphics object, fill the background rectangle (e.Bounds) with
> > > > > > > the
> > > > > > > color
> > > > > > > of
> > > > > > > your choice, and draw the tab's text on top of it.
> > > > > > >
> > > > > > > Private Sub tabControl1_DrawItem(ByVal sender As Object,[/color][/color][/color]
ByVal[color=blue][color=green][color=darkred]
> > > > > > > e
> > > > > > > As
> > > > > > > DrawItemEventArgs)
> > > > > > > Dim tc As TabControl = CType(sender, TabControl)
> > > > > > > Dim tp As TabPage = tc.TabPages(e.index)
> > > > > > > Dim strTitle As String = tp.Text
> > > > > > > Dim g As Graphics = e.Graphics
> > > > > > > Dim theBrush As Brush = New SolidBrush(Me.ForeColor)
> > > > > > > Dim sf As StringFormat = New StringFormat()
> > > > > > > sf.Alignment = StringAlignment.Center
> > > > > > > g.FillRectangle(New SolidBrush(tp.BackColor),e.Bounds)
> > > > > > > g.DrawString(strTitle, tc.Font, theBrush, e.Bounds, sf)
> > > > > > > End Sub
> > > > > > >
> > > > > > > "Michael Turner" <fishing@m-turner.co.uk> wrote in message
> > > > > > > news:Oaf8ZlEsEHA.376@TK2MSFTNGP14.phx.gbl:
> > > > > > > > Hi Guys
> > > > > > > >
> > > > > > > > Having problem with the tab control, I need to set the
> > > > > > > > background
> > > > > > > > color
> > > > > > > > to
> > > > > > > > something different than the standard, I have found code on
> > > > > > > > the
> > > > > > > > web
> > > > > > > > and
> > > > > > > > now
> > > > > > > > can redraw the tabpage buttons so the are set to the right[/color]
> > color,[color=darkred]
> > > > > > > > I
> > > > > > > > can
> > > > > > > > obviously change the tabpage colour but I am left with a
> > > > > > > > grey
> > > > > > > > top
> > > > > > > > edge(Where
> > > > > > > > there are no buttons) when the background of the form is
> > > > > > > > changed
> > > > > > > > any
> > > > > > > > ideas
> > > > > > > > on what I can do?
> > > > > > > >
> > > > > > > > Mike.
> > > > > > >
> > > > > > >
> > > > >
> > > > >
> > >
> > >[/color][/color]
>
>[/color]