Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Disable tabPage?
 

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? 
MigrationUser 1  Friday, September 05, 2003 6:24 AM
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>
MigrationUser 1  Sunday, September 07, 2003 11:47 AM
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.
MigrationUser 1  Sunday, September 07, 2003 3:11 PM
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
MigrationUser 1  Monday, September 08, 2003 1:32 PM

You can use google to search for other answers

Custom Search

More Threads

• Inconsistent designer behavior
• Windows application with HtML Templates
• Custom combobox behavior
• Mouse Wheel Scroll C#
• "Feature packed" datepicker control released!
• error HRESULT E_FAIL has been returned from a call to a COM componet.
• Failure to load designer due to VS2005B2 fault
• User control properties : Drop down list?
• Menu Button (outside of a toolbar)
• Outlook Address Card View