Version

TabSelecting Event

Cancelable event that occurs before an MdiTab is selected.
Syntax
'Declaration
 
Public Event TabSelecting As CancelableMdiTabEventHandler
public event CancelableMdiTabEventHandler TabSelecting
Event Data

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

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
Tab Returns the associated MdiTab
Remarks

The TabSelecting is invoked when the MdiTabGroup.SelectedTab is about to change. Selecting an MdiTab will activate the Form with which it is associated.

Since the ActiveTab represents the active mdi tab and mdi child form activation is maintained by their zorder, the ActiveTab must be the MdiTabGroup.SelectedTab of its TabGroup. Since the ActiveTab must be selected, as the ActiveTab changes, the TabSelecting event will be invoked.

Note: The TabSelecting event may not always be cancellable since the activation/selection may occur as a result of an external action - e.g. when the mdi child is first created.

Example
The following sample demonstrates how to use the information passed to the TabSelecting 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_TabSelecting(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTabbedMdi.CancelableMdiTabEventArgs) Handles ultraTabbedMdiManager1.TabSelecting
    ' The 'TabSelecting' event is invoked when a tab is about to 
    ' be selected in an MdiTabGroup.
    '

    ' The 'Cancel' parameter may be set to true to 
    ' prevent the selection operation from occuring.
    ' Note, there are times when the activation of a tab 
    ' is initiated externally, e.g. when a new mdi child
    ' is created, that the event may not be cancellable.
    '
    'e.Cancel = True

    ' The 'Tab' parameter returns the MdiTab instance that 
    ' will be selected.
    Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()

    sb.Append("TabSelecting:")

    sb.AppendFormat("Tab ['{0}'] will be selected.", e.Tab)
    sb.AppendFormat(" The current selected tab in tab group ['{0}'] is '{1}'", e.Tab.TabGroup, e.Tab.TabGroup.SelectedTab)

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

private void ultraTabbedMdiManager1_TabSelecting(object sender, Infragistics.Win.UltraWinTabbedMdi.CancelableMdiTabEventArgs e)
{
	// The 'TabSelecting' event is invoked when a tab is about to 
	// be selected in an MdiTabGroup.
	//

	// The 'Cancel' parameter may be set to true to 
	// prevent the selection operation from occuring.
	// Note, there are times when the activation of a tab 
	// is initiated externally, e.g. when a new mdi child
	// is created, that the event may not be cancellable.
	//
	//e.Cancel = true;

	// The 'Tab' parameter returns the MdiTab instance that 
	// will be selected.
	System.Text.StringBuilder sb = new System.Text.StringBuilder();

	sb.Append("TabSelecting:");

	sb.AppendFormat("Tab ['{0}'] will be selected.", e.Tab);
	sb.AppendFormat(" The current selected tab in tab group ['{0}'] is '{1}'", e.Tab.TabGroup, e.Tab.TabGroup.SelectedTab);

	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