Custom Tab renderer for Syncfusion TabControlAdv

First you need to create a new class that should inherit any existing TabRenderer. For this example i am taking Metro renderer. So the code is written below

 

public class TabRender : TabRendererMetro
{
public new static string TabStyleName
{
get { return "TabRender"; }
}

static TabRender()
{
TabRendererFactory.RegisterTabType(TabStyleName, typeof (TabRender), TabPanelPropertyExtender);
}

public TabRender(ITabControl parent, ITabPanelRenderer panelRenderer)
: base(parent, panelRenderer)
{
}

protected override void DrawBackground(DrawTabEventArgs drawItemInfo)
{
Brush BackBrush = new SolidBrush(Color.DarkGray);
var tab = ((TabControlAdv) TabControl).TabPages[drawItemInfo.Index];
var bgColor = Color.FromArgb(199, 216, 237);
if (tab.Name == "Pinned")
{
bgColor = Color.Red;
if ((drawItemInfo.State & DrawItemState.Selected) > 0)
bgColor = Color.FromArgb(210, 238, 229);
Brush pinnedBrush = new SolidBrush(bgColor);
drawItemInfo.Graphics.FillRectangle(pinnedBrush, drawItemInfo.Bounds);
}
else
{
if ((drawItemInfo.State & DrawItemState.Selected) > 0)
{
drawItemInfo.Graphics.FillRectangle(BackBrush, drawItemInfo.Bounds);
BackBrush.Dispose();
}
else
{
Brush whiteBrush = new SolidBrush(Color.White);
drawItemInfo.Graphics.FillRectangle(whiteBrush, drawItemInfo.Bounds);
whiteBrush.Dispose();
}

}
}

}

So this line is used to register the new class as Renderer

TabRendererFactory.RegisterTabType(TabStyleName, typeof (TabRender), TabPanelPropertyExtender);

After that all you have to do is assign this via the properties of the tab or by using the designer file.

this.tabControl.TabStyle = typeof(CheckSynfusion.TabRender);