Version

TabClosing Event

Cancelable event that occurs before an MdiTab is closed.
Syntax
'Declaration
 
Public Event TabClosing As CancelableMdiTabEventHandler
public event CancelableMdiTabEventHandler TabClosing
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 TabClosing event is invoked when MdiTab.Close method is invoked, the close button is pressed or the "Close" menu option in the tab's context menu is selected. If the event is cancelled, no action is taken. Otherwise, the action specified in the MdiTabSettingsResolved.TabCloseAction is taken and the TabClosed event is invoked.

Example
The following sample demonstrates how to use the information passed to the TabClosing 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_TabClosing(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTabbedMdi.CancelableMdiTabEventArgs) Handles ultraTabbedMdiManager1.TabClosing
    ' The 'TabClosing' event is invoked when the tab is
    ' about to be "closed". What actually will occur to 
    ' the tab and associated form will depend upon the 
    ' resolved TabCloseAction.
    '

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

    If e.Tab.SettingsResolved.TabCloseAction = MdiTabCloseAction.Close Then
        If TypeOf e.Tab.Form Is EditForm Then
            If Not (CType(e.Tab.Form, EditForm)).Save() Then
                e.Cancel = True
            End If
        End If
    End If
End Sub
using Infragistics.Win;
using Infragistics.Win.UltraWinTabs;
using Infragistics.Win.UltraWinTabbedMdi;

private void ultraTabbedMdiManager1_TabClosing(object sender, Infragistics.Win.UltraWinTabbedMdi.CancelableMdiTabEventArgs e)
{
	// The 'TabClosing' event is invoked when the tab is
	// about to be "closed". What actually will occur to 
	// the tab and associated form will depend upon the 
	// resolved TabCloseAction.
	//
	
	// The 'Cancel' parameter may be set to true to 
	// prevent the close action from occuring.
	//
	// e.Cancel = true;

	if (e.Tab.SettingsResolved.TabCloseAction == MdiTabCloseAction.Close)
	{
		if (e.Tab.Form is EditForm)
		{
			if (! ((EditForm)e.Tab.Form).Save() )
				e.Cancel = true;
		}
	}
}
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