Articles in this section
Category / Section

How to custom paint the tab panel in the WinForms TabControlAdv?

1 min read

Customize the tab panel

You should derive TabPanelProperty3D or TabPanelProperty2D depends upon the style of TabControlAdv and override the OnPaintPanelBackground method for this purpose. Then register the CustomTabPanelProperty with the TabRenderer style. After that apply the TabStyle to the TabControlAdv. Please refer the below code snippet which illustrates this:

C#

public Form1()
{
    InitializeComponent();
    TabRendererFactory.RegisterTabType(TabRendererMetro.TabStyleName, typeof(TabRendererMetro), new CustomTabPanelProperty());
    this.tabControlAdv1.TabStyle = typeof(TabRendererMetro);
}
public class CustomTabPanelProperty : Syncfusion.Windows.Forms.Tools.TabPanelProperty3D
{
    public override void OnPaintPanelBackground(ITabControl tabControl, Graphics g, Color bgColor, Rectangle bounds)
    {
       System.Drawing.Drawing2D.LinearGradientBrush lgb = new System.Drawing.Drawing2D.LinearGradientBrush(bounds, Color.Red, Color.GreenYellow, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
       g.FillRectangle(lgb, bounds);
    }
}

VB

Public Sub New()
    InitializeComponent()
    TabRendererFactory.RegisterTabType(TabRendererMetro.TabStyleName, GetType(TabRendererMetro), New CustomTabPanelProperty())
    Me.tabControlAdv1.TabStyle = GetType(TabRendererMetro)
End Sub
Public Class CustomTabPanelProperty
    Inherits Syncfusion.Windows.Forms.Tools.TabPanelProperty3D
    Public Overrides Sub OnPaintPanelBackground(ByVal tabControl As ITabControl, ByVal g As Graphics, ByVal bgColor As Color, ByVal bounds As Rectangle)
       Dim lgb As New System.Drawing.Drawing2D.LinearGradientBrush(bounds, Color.Red, Color.GreenYellow, System.Drawing.Drawing2D.LinearGradientMode.Vertical)
       g.FillRectangle(lgb, bounds)
    End Sub
End Class

Show the customized tab panel in TabControlAdv

Customized TabPanel in TabControlAdv

Samples:

C#: PaintCustomPanel_C#

VB: PaintCustomPanel_VB

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