Disable tabPage?

When I set the enable to false on a tabPage the text on the header isn't gray

Is there some simple way to implement this functionality  


Answer this question

Disable tabPage?

  • Unus

    Thanks. Guess I could use Magic although it makes the job a little harder lacking design time support.

    I also looked at the CreateItem event, but that didn't seem to help me much.

  • kbabaria

    Sorry, no easy way. The ForeColor and BackColor properties don't work either. If you really need this functionality, you can either create your own control or use someone else’s. You can find a free tab control, among other controls, that does expose color functionality at <a href="http://www.dotnetmagic.com/index.html">Magic User Interface Library for .NET</a>
  • nmueggler

    Set the property TabControl1.DrawMode = OwnerDrawFixed.
    Modify the appearance in the TabControls DrawItem Event.

        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 TextBrush As New SolidBrush(e.ForeColor)
            Dim sf As New StringFormat

            sf.Alignment = StringAlignment.Center
            sf.LineAlignment = StringAlignment.Center

            If Not DirectCast(sender, TabControl).TabPages(e.Index).Enabled Then
                TextBrush.Color = SystemColors.GrayText
            End If

            e.Graphics.DrawString(s, e.Font, TextBrush, r, sf)

            TextBrush.Dispose()
            sf.Dispose()

        End Sub

  • Disable tabPage?