Version

TabMoving Event

Event that occurs when an MdiTab is about to be repositioned.
Syntax
'Declaration
 
Public Event TabMoving As MdiTabMovingEventHandler
public event MdiTabMovingEventHandler TabMoving
Event Data

The event handler receives an argument of type MdiTabMovingEventArgs containing data related to this event. The following MdiTabMovingEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
Tab (Inherited from Infragistics.Win.UltraWinTabbedMdi.CancelableMdiTabEventArgs)Returns the associated MdiTab
TabGroup Returns the MdiTabGroup that will contain the tab being moved.
TabIndex Returns the index at which MdiTab that will be inserted in the Tabs collection of the TabGroup.
Remarks

The TabMoving event is invoked before an MdiTab is moved from one position to another. This may be a reposition in the Tabs of the containing TabGroup or as a result of being moved to a different MdiTabGroup. The end user may reposition a tab by either dragging the tab or via the right click context menu. Where the user may reposition the tabs is dependant on many settings including the tab's MdiTabSettingsResolved.AllowDrag, the AllowDrop of the tab groups, as well as the MaxTabGroups, AllowHorizontalTabGroups and AllowVerticalTabGroups. Programatically, the tab may be repositioned to a specific MdiTabGroup using the MdiTab.MoveToGroup or to a new MdiTabGroup using the MoveToNewGroup(MdiTab) method. A tab may also be repositioned using its MdiTab.Reposition method or it may be repositioned by its containing group using the MoveAllTabs.

Example
The following sample demonstrates how to use the information passed to the TabMoving event.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinTabs
Imports Infragistics.Win.UltraWinTabbedMdi

Private Sub ultraTabbedMdiManager1_TabMoving(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTabbedMdi.MdiTabMovingEventArgs) Handles ultraTabbedMdiManager1.TabMoving
    ' The 'TabMoving' event is invoked when a tab is about
    ' to be repositioned. It may be repositioned within a 
    ' group or moved to another group.

    ' The 'Cancel' parameter may be set to true to 
    ' prevent the move operation from occuring.
    '
    'e.Cancel = True

    Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
    sb.AppendFormat("TabMoving: Tab ['{0}'] ", e.Tab)

    ' The 'Tab' parameter returns the MdiTab object that is
    ' about to be repositioned. The 'TabGroup' parameter returns 
    ' the TabGroup that will contain the tab. The 'TabIndex'
    ' parameter returns the index at which the tab will be 
    ' positioned.

    If e.Tab.TabGroup Is e.TabGroup Then
        ' it is being repositioned within its containing group
        Dim index As Integer = e.Tab.TabGroup.Tabs.IndexOf(e.Tab)
        sb.AppendFormat("is being moved within its group from index {0} to {1}.", index, e.TabIndex)
    ElseIf e.TabGroup.Tabs.Count = 0 Then
        ' it is being repositioned to a new group
        sb.Append("is being moved to a new MdiTabGroup. ")
        sb.AppendFormat("The new group is located at index: {0}.", e.TabGroup.Manager.TabGroups.IndexOf(e.TabGroup))
    Else
        ' it is being repositioned in a different group
        sb.Append("is being moved to an existing tab group. ")
        sb.AppendFormat("The tab will be positioned at index {0}", e.TabIndex)
    End If

    System.Diagnostics.Debug.WriteLine(sb.ToString())
End Sub
using Infragistics.Win;
using Infragistics.Win.UltraWinTabs;
using Infragistics.Win.UltraWinTabbedMdi;

private void ultraTabbedMdiManager1_TabMoving(object sender, Infragistics.Win.UltraWinTabbedMdi.MdiTabMovingEventArgs e)
{
	// The 'TabMoving' event is invoked when a tab is about
	// to be repositioned. It may be repositioned within a 
	// group or moved to another group.
	
	// The 'Cancel' parameter may be set to true to 
	// prevent the move operation from occuring.
	//
	//e.Cancel = true;

	System.Text.StringBuilder sb = new System.Text.StringBuilder();
	sb.AppendFormat("TabMoving: Tab ['{0}'] ", e.Tab);

	// The 'Tab' parameter returns the MdiTab object that is
	// about to be repositioned. The 'TabGroup' parameter returns 
	// the TabGroup that will contain the tab. The 'TabIndex'
	// parameter returns the index at which the tab will be 
	// positioned.

	if (e.Tab.TabGroup == e.TabGroup)
	{
		// it is being repositioned within its containing group
		int index = e.Tab.TabGroup.Tabs.IndexOf(e.Tab);
		sb.AppendFormat("is being moved within its group from index {0} to {1}.", index, e.TabIndex);
	}
	else if (e.TabGroup.Tabs.Count == 0) 
	{
		// it is being repositioned to a new group
		sb.Append("is being moved to a new MdiTabGroup. ");
		sb.AppendFormat("The new group is located at index: {0}.", e.TabGroup.Manager.TabGroups.IndexOf(e.TabGroup));
	}
	else
	{
		// it is being repositioned in a different group
		sb.Append("is being moved to an existing tab group. ");
		sb.AppendFormat("The tab will be positioned at index {0}", e.TabIndex);
	}

	System.Diagnostics.Debug.WriteLine( sb.ToString() );
}
Requirements

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

See Also