'Declaration Public Overloads Sub Sort( _ ByVal direction As SortDirection _ )
public void Sort( SortDirection direction )
Imports Infragistics.Win Imports Infragistics.Win.UltraWinTabs Imports Infragistics.Win.UltraWinTabControl Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click ' The VisibleTabs collection exposes a Sort method ' with 3 overloads. ' Calling the method without any parameters will do ' an ascending case-sensitive sort based on the ' tabs' Text values. Me.ultraTabControl1.VisibleTabs.Sort() ' The second overload allows you to specify whether ' to sort ascending or descending based on the ' tabs' (case-sensitive) Text values Me.ultraTabControl1.VisibleTabs.Sort(SortDirection.Descending) ' The third overload allows you to specify a custom ' comparer. In this case, a comparer that will do a ' case-insensitive sort. Me.ultraTabControl1.VisibleTabs.Sort(New MyTabComparer(SortDirection.Descending)) ' Calling the Sort method affects tab placement in the ' 'VisibleTabs' collection and changes each tab's 'VisibleIndex' ' property but does not affect the tab's 'Index' property or ' its position in the 'Tabs' collection. ' Tab placement in the 'VisibleTabs' collection can ' also be changed by setting the tab's 'VisibleIndex' ' property or calling its 'Reposition' method Dim utab As UltraTab = Me.ultraTabControl1.Tabs(2) utab.VisibleIndex = 0 utab.Reposition(Me.ultraTabControl1.Tabs(1), RelativePosition.Before) ' The 'VisibleTabs' collection also exposes properties and ' methods for filtering out non-selectable tabs, i.e. tabs ' whose 'Visible' or 'Enabled' property is set to false. utab = Me.ultraTabControl1.VisibleTabs.FirstSelectableTab utab = Me.ultraTabControl1.VisibleTabs.LastSelectableTab utab = Me.ultraTabControl1.VisibleTabs.GetNextSelectableTab(utab, True) utab = Me.ultraTabControl1.VisibleTabs.GetPreviousSelectableTab(utab, True) ' Note: the 2nd parameter to the method calls above specifies ' whether to wrap around when the last or first selectable tab ' is passed in. End Sub Private Class MyTabComparer Implements IComparer Private direction As SortDirection Public Sub New(ByVal direction As SortDirection) Me.direction = direction End Sub Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare Dim tab1 As UltraTab = x Dim tab2 As UltraTab = y Dim string1 As String = tab1.Text Dim string2 As String = tab2.Text Dim ret As Integer If string1 Is Nothing Then ret = -1 ElseIf string2 Is Nothing Then ret = 1 Else ' Do a case-insensitive compare ret = String.Compare(string1, string2, True, System.Globalization.CultureInfo.CurrentCulture) End If ' If descending then flip the sign If Me.direction = SortDirection.Descending Then ret *= -1 End If Return ret End Function End Class
using System.Diagnostics; using Infragistics.Win; using Infragistics.Win.UltraWinTabs; using Infragistics.Win.UltraWinTabControl; private void button9_Click(object sender, System.EventArgs e) { // The VisibleTabs collection exposes a Sort method // with 3 overloads. // Calling the method without any parameters will do // an ascending case-sensitive sort based on the // tabs' Text values. this.ultraTabControl1.VisibleTabs.Sort(); // The second overload allows you to specify whether // to sort ascending or descending based on the // tabs' (case-sensitive) Text values this.ultraTabControl1.VisibleTabs.Sort( SortDirection.Descending ); // The third overload allows you to specify a custom // comparer. In this case, a comparer that will do a // case-insensitive sort. this.ultraTabControl1.VisibleTabs.Sort( new MyTabComparer(SortDirection.Descending) ); // Calling the Sort method affects tab placement in the // 'VisibleTabs' collection and changes each tab's 'VisibleIndex' // property but does not affect the tab's 'Index' property or // its position in the 'Tabs' collection. // Tab placement in the 'VisibleTabs' collection can // also be changed by setting the tab's 'VisibleIndex' // property or calling its 'Reposition' method UltraTab tab = this.ultraTabControl1.Tabs[2]; tab.VisibleIndex = 0; tab.Reposition( this.ultraTabControl1.Tabs[1], RelativePosition.Before ); // The 'VisibleTabs' collection also exposes properties and // methods for filtering out non-selectable tabs, i.e. tabs // whose 'Visible' or 'Enabled' property is set to false. tab = this.ultraTabControl1.VisibleTabs.FirstSelectableTab; tab = this.ultraTabControl1.VisibleTabs.LastSelectableTab; tab = this.ultraTabControl1.VisibleTabs.GetNextSelectableTab( tab, true ); tab = this.ultraTabControl1.VisibleTabs.GetPreviousSelectableTab( tab, true ); // Note: the 2nd parameter to the method calls above specifies // whether to wrap around when the last or first selectable tab // is passed in. } private class MyTabComparer : IComparer { private SortDirection direction; internal MyTabComparer( SortDirection direction ) { this.direction = direction; } int IComparer.Compare(object x, object y) { UltraTab tab1 = x as UltraTab; UltraTab tab2 = y as UltraTab; string string1 = tab1.Text; string string2 = tab2.Text; int ret; if ( string1 == null ) ret = -1; else if ( string2 == null ) ret = 1; else { // Do a case-insensitive compare ret = string.Compare( string1, string2, true, System.Globalization.CultureInfo.CurrentCulture); } // If descending then flip the sign if ( this.direction == SortDirection.Descending ) ret *= -1; return ret; } }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2