Articles in this section
Category / Section

How to customize the appearance of the WinForms TabControlAdv while HotTracking?

4 mins read

Customize the appearance of TabControlAdv while HotTracking

You can customize the appearance of the TabControlAdv while HotTracking. This can be achieved by handling the event, DrawItem in the TabControlAdv. The argument, DrawTabEventArgs gets the data for the Syncfusion.Windows.Forms.Tools.TabControlAdv.DrawItem event handler in the TabControlAdv. Within this event handler, check whether the TabItem is being HotTracked, and when it is, set the desired forecolor and backcolor to the DrawTabEventArgs object. The arguments contain all the necessary information that helps the user to paint the specified tab item. The following are the properties and functions.

Properties:

1. BackColor - Gets or sets the background color of the specified tab item.

2. ForeColor - Gets or sets the forecolor of the specified tab item text.

3. Font - Gets or sets the font of the specified tab item.

4. Bounds - Gets or sets the bounds of the specified tab item. They include the space for the border.

5. BoundsInterior - Gets or sets the bounds of the specified tab item without having space for the borders.

6. Graphics - Returns the graphics surface to draw the tab item.

7. Index - Returns the index value of the tab item.

8. DrawItemState - Gets or sets the item state.

9. TextBrush - Gets or sets the brush to draw the text.

 

Functions:

1. DrawBackground - Draws the background.

2. DrawBorders - Draws the borders within the bounds specified.

3. DrawInterior - Draws the text and image within the bounds specified.

C#

//Enables the HotTrack. It helps to change the appearance of the TabControlAdv on mouse hover.
this.tabControlAdv1.HotTrack = true;
//Draws the Tab item.
this.tabControlAdv1.DrawItem += new DrawTabEventHandler(tabControlAdv1_DrawItem);
void tabControlAdv1_DrawItem(object sender, DrawTabEventArgs drawItemInfo)
{
    //Checks whether the HotTracking is in progress.
    if ((drawItemInfo.State & DrawItemState.HotLight) > 0)
    {
        drawItemInfo.ForeColor = Color.Red;
        drawItemInfo.BackColor = Color.Khaki;
        drawItemInfo.Font = new Font("Segoe Marker", 12.0F, FontStyle.Italic);
    }
    //Draws the default background and interior.
    drawItemInfo.DrawBackground();
    drawItemInfo.DrawInterior();
}

VB

'Enables the HotTrack. It helps to change the appearance of the TabControlAdv on mouse hover.
Me.tabControlAdv1.HotTrack = True
'Draws the Tab item.
AddHandler tabControlAdv1.DrawItem, AddressOf tabControlAdv1_DrawItem
Private Sub tabControlAdv1_DrawItem(ByVal sender As Object, ByVal drawItemInfo As DrawTabEventArgs)
   'Checks whether the HotTracking is in progress.
   If (drawItemInfo.State And DrawItemState.HotLight) > 0 Then
     drawItemInfo.ForeColor = Color.Red
     drawItemInfo.BackColor = Color.Khaki
     drawItemInfo.Font = New Font("Segoe Marker", 12.0F, FontStyle.Italic)
   End If
   'Draws the default background and interior.
   drawItemInfo.DrawBackground()
   drawItemInfo.DrawInterior()
End Sub

 

Note:

The property named “HotTrack” in TabControlAdv changes the appearance of the TabPageAdv when the mouse passes over them.

 


Before enabling the HotTrack property

Figure 1: Before enabling the HotTrack property

After enabling the HotTrack property

Figure 2: After enabling the HotTrack property

Before customize the appearance of TabPageAdv when HotTrack is enabled

Figure 3: Before customizing the appearance of the TabPageAdv when HotTrack property is enabled

Before customize the back and forecolor of TabPageAdv when HotTrack is enabled

Figure 4: After customizing the forecolor and backcolor of the TabPageAdv when HotTrack property is enabled

After customize the appearance, back and forecolor of TabPageAdv when HotTrack is enabled

Figure 5: After customizing the appearance, HotTrack enabled and Forecolor, BackColor and Font specified

Samples:

C#: TabControlAdv_HotTrack_C#

VB: TabControlAdv_HotTrack_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied