We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to prevent tabs from getting realigned when in Multiline mode

Platform: WinForms |
Control: TabControlAdv |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

KeepSelectedTabInFrontRow was added in version 1.6.1.0 to address this issue. For earlier versions, please derive from our base TabControlExt 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.NET] '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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon