Version

BeforeToolActivate Event (UltraToolbarsManager)

Occurs before a tool becomes the active tool.
Syntax
'Declaration
 
Public Event BeforeToolActivate As CancelableToolEventHandler
public event CancelableToolEventHandler BeforeToolActivate
Event Data

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

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
Tool The tool.
Remarks

This event is generated before a tool becomes the active tool, meaning it received focus.

The AfterToolActivate event is generated after a tool becomes the active tool.

The AfterToolDeactivate event is generated after a tool becomes inactive.

The ActiveTool property can be used to set or return the active tool.

Example
The following code demonstrates how to access the information passed in the event arguments of the BeforeToolActivate event and conditionally cancel the 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 System.Diagnostics
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinToolbars

	Private Sub UltraToolbarsManager1_BeforeToolActivate(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinToolbars.CancelableToolEventArgs) Handles UltraToolbarsManager1.BeforeToolActivate

		Dim dr As DialogResult = MessageBox.Show(Me, "The tool with key '" + e.Tool.Key + "' is about to be activated. Do you want to cancel activation?", "Cancelable Toolbar Event", MessageBoxButtons.YesNo)

		If dr = DialogResult.Yes Then
			e.Cancel = True
		End If

	End Sub
using System.Diagnostics;
using Infragistics.Win;
using Infragistics.Win.UltraWinToolbars;

		private void ultraToolbarsManager1_BeforeToolActivate(object sender, Infragistics.Win.UltraWinToolbars.CancelableToolEventArgs e)
		{

			DialogResult dr =  MessageBox.Show(this, "The tool with key '" + e.Tool.Key + "' is about to be activated. Do you want to cancel activation?", "Cancelable Toolbar Event", MessageBoxButtons.YesNo);

			if (dr == DialogResult.Yes)
				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