Preventing tabs from getting realigned in WinForms TabControlAdv.
Prevent tabs from getting realigned when in multiline mode
KeepSelectedTabInFrontRow was added in version 1.6.1.0 to address this issue. For earlier versions, please derive from our base WinForms TabControl class and do the following. This code will not move the selected tab to the front row when in Multiline mode:
C#
// Custom tab control will prevent tab realignment in Multiline mode. public class MyTabControlExt : TabControlExt { // Plugin the custom MyMultilineTabPanelRenderer class. protected override void RendererChanged(TabPanelRenderer rendererNew) { if(rendererNew == null && this.Multiline) { rendererNew = new MyMultilineTabPanelRenderer(this); } base.RendererChanged(rendererNew); } } // Custom MyMultilineTabPanelRenderer to prevent tab realignment. public class MyMultilineTabPanelRenderer : MultilineTabPanelRenderer { public MyMultilineTabPanelRenderer(ITabControl parent) : base(parent) { } protected override void ValidateSelectedTabsPosition() { // Don’t call the base class method which will try to move the selected tab to the front row. } }
VB
'Custom tab control will prevent tab realignment in Multiline mode. Public Class MyTabControlExt Inherits TabControlExt ' Plugin the custom MyMultilineTabPanelRenderer class. Protected Overrides Sub RendererChanged(ByVal rendererNew As TabPanelRenderer) If rendererNew Is Nothing AndAlso Me.Multiline Then rendererNew = New MyMultilineTabPanelRenderer(Me) End If MyBase.RendererChanged(rendererNew) End Sub 'RendererChanged End Class ’MyTabControlExt 'Custom MyMultilineTabPanelRenderer to prevent tab realignment. Public Class MyMultilineTabPanelRenderer Inherits MultilineTabPanelRenderer Public Sub New(ByVal parent As ITabControl) MyBase.New(parent) End Sub Protected Overrides Sub ValidateSelectedTabsPosition() End Sub 'ValidateSelectedTabsPosition End Class 'MyMultilineTabPanelRenderer 'Don’t call the base class method which will try to move the selected tab
Conclusion
I hope you enjoyed learning about preventing tabs from getting realigned in WinForms TabControlAdv.
You can refer to our WinForms TabControl feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!