Do you know Beter TabControl ?

  • Thread starter Thread starter willem
  • Start date Start date
W

willem

Where can I find a beter TabControl component (similar Tab into
VisualStudio IDE) ?

Now I know only Magic Control of Crownwood Consulting Ltd (but I think it a
bit costly).

thanks
willem
 
Éric Moreau said:
What feature are you looking for?

--

HTH

Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)

Hi Eric,
I'm looking for principally a TabControl with possibility of change colors
of every part (pages, tabs, fonts, borders).
Beter if this control looks like IDE Tabs in Visual Studio but this is not
necessary.

thanks
willem
 
Do what you want to do in the DrawItem event:

Here is a class you can add to your project that gives you a real Enabled
property:

Option Strict On

'===========================================================================
==========
' Classe : TabControlEx.vb
'
' Auteur : Eric Moreau
' Concept S2i inc.
'
' Description : System.Windows.Forms.TabControl Extender
'
' Utilisation : 1. Add a regular TabControl to your form
' 2. In the " Windows Form Designer generated code "
section,
' replace System.Windows.Forms.TabControl by
TabControlEx (2 places)
' 3. In the Form_Load event (or a similar place), add this
line
' YourTabControlName.DrawMode =
TabDrawMode.OwnerDrawFixed
' 4. If you want to disable a tabpage, add this line
' YourTabControlName.DisablePage(YourTabPageName)
'
' Historique :
' Auteur Date Intervention
' ----------------- --------------- ----------------------------------------
---------
' Eric Moreau 2004/02/15 Création
'===========================================================================
==========

Public Class TabControlEx
Inherits System.Windows.Forms.TabControl

Private Const WM_LBUTTONDOWN As Integer = &H201

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_LBUTTONDOWN Then
Dim pt As New Point(m.LParam.ToInt32)
Dim index As Integer
For index = 0 To Me.TabPages.Count - 1
If GetTabRect(index).Contains(pt) Then
If TabPages(index).Enabled Then
MyBase.WndProc(m)
End If
Exit Sub
End If
Next
End If
MyBase.WndProc(m)
End Sub

Protected Overrides Sub OnKeyDown(ByVal ke As
System.Windows.Forms.KeyEventArgs)
Dim currentIndex As Integer = Me.SelectedIndex
Dim index As Integer
If ke.KeyCode = Keys.Left AndAlso Not (ke.Alt AndAlso Not
ke.Control) Then
For index = currentIndex - 1 To 0 Step -1
If TabPages(index).Enabled Then
Me.SelectedIndex = index
Exit For
End If
Next
ke.Handled = True
ElseIf ke.KeyCode = Keys.Right AndAlso Not (ke.Alt AndAlso Not
ke.Control) Then
For index = currentIndex + 1 To TabPages.Count - 1
If TabPages(index).Enabled Then
Me.SelectedIndex = index
Exit For
End If
Next
ke.Handled = True
End If
MyBase.OnKeyDown(ke)
End Sub

Public Sub DisablePage(ByRef pTabPage As TabPage)
With pTabPage
.Enabled = False
'.Text = "(* " & .Text & " *)"
End With
End Sub

Private Sub TabControlEx_DrawItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles MyBase.DrawItem
Dim intOffsetLeft As Int32
Dim intOffsetTop As Int32
Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds)
Dim r2 As RectangleF
Dim ItemBrush As New SolidBrush(Me.BackColor)
Dim b As Brush ' SolidBrush = New
SolidBrush(TabControl1.ForeColor)
If Me.TabPages(e.Index).Enabled Then
b = Brushes.Black
Else
b = Brushes.Gray
End If

Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

Dim im As Bitmap
If Me.TabPages(e.Index).ImageIndex <> -1 Then
im = CType(Me.ImageList.Images(Me.TabPages(e.Index).ImageIndex),
Bitmap)
End If

If Me.TabPages(e.Index).ImageIndex <> -1 Then
r2 = New RectangleF(r.X + (im.Width \ 2), r.Y, r.Width,
r.Height)
Else
r2 = New RectangleF(r.X, r.Y, r.Width, r.Height)
End If

If CBool(e.State And DrawItemState.Selected) Then
e.Graphics.FillRectangle(ItemBrush, e.Bounds)
e.Graphics.DrawString(Me.TabPages(e.Index).Text, e.Font, b, r2,
sf)
'e.Graphics.DrawString(TabControl1.TabPages(e.Index).Text,
e.Font, Brushes.Red, r2, sf)
intOffsetLeft = 5
intOffsetTop = 5 '4
Else
e.Graphics.DrawString(Me.TabPages(e.Index).Text, e.Font, b, r2,
sf)
'e.Graphics.DrawString(TabControl1.TabPages(e.Index).Text,
e.Font, Brushes.Blue, r2, sf)
intOffsetLeft = 2
intOffsetTop = 2 '4
End If

If Me.TabPages(e.Index).ImageIndex <> -1 Then
Me.ImageList.Draw(e.Graphics, Convert.ToInt32(r.Left) +
intOffsetLeft, Convert.ToInt32(r.Top) + intOffsetTop,
Me.TabPages(e.Index).ImageIndex)
End If
End Sub
End Class


--

HTH

Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
 
Where can I find a beter TabControl component (similar Tab into
VisualStudio IDE) ?

Now I know only Magic Control of Crownwood Consulting Ltd (but I think it a
bit costly).

thanks
willem

If you download the VB Resource kit, it comes with ComponentOne studio
which has a pretty good Tab control.
 
If you download the VB Resource kit, it comes with ComponentOne studio
which has a pretty good Tab control.
Sorry, I have here ComponentOne but I don't see a TabControl
willem
 
Hi Eric,
Thanks for the source.
But it's impossible to change colors of all control (for example 3d borders
and some lines stay with standard Windows colors).
Impossible a complete control of design to have.

willem
 
Back
Top