Version

BeforeCellActivate Event

Occurs before a cell becomes active.
Syntax
'Declaration
 
Public Event BeforeCellActivate As CancelableCellEventHandler
public event CancelableCellEventHandler BeforeCellActivate
Event Data

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

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
Cell Returns a reference to the cell of interest.
Remarks

Thecellargument returns a reference to an UltraGridCell object that can be used to set properties of, and invoke methods on, the cell that will be activated. You can use this reference to access any of the returned cell's properties or methods.

Thecancelargument enables you to programmatically prevent the cell from being activated. This argument can be used to prevent the cell from activating unless a certain condition is met.

This event is generated before a cell is activated, which means it has been given focus.

TheBeforeCellDeactivateevent is generated before a cell is deactivated, meaning it will lose focus.

TheAfterCellActivateevent, which occurs after a cell is activated, is generated after this event, providedcancelis not set to True.

Example
The following sample code illustrates how one can use combination of BeforeCellActivate and BeforeCellDeactivate to change the ActiveCell's appearance. ActiveCellAppearance property off the UltraGridOverride can be used to accomplish the same thing.

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.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub UltraGrid1_BeforeCellActivate(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelableCellEventArgs) Handles ultraGrid1.BeforeCellActivate

      ' Set the appearance of the cell right before the cell is about to be activated.
      ' In the BeforeCellDeactivate, we will reset the BackColor.
      e.Cell.Appearance.BackColor = Color.LightYellow

  End Sub

  Private Sub UltraGrid1_BeforeCellDeactivate(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ultraGrid1.BeforeCellDeactivate

      ' Reset BackColor the appearance of the cell right before the cell is about
      ' to be deactivated.
      Me.ultraGrid1.ActiveCell.Appearance.ResetBackColor()

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_BeforeCellActivate(object sender, Infragistics.Win.UltraWinGrid.CancelableCellEventArgs e)
{

	// Set the appearance of the cell right before the cell is about to be activated.
	// In the BeforeCellDeactivate, we will reset the BackColor.
	e.Cell.Appearance.BackColor = Color.LightYellow;

}

private void ultraGrid1_BeforeCellDeactivate(object sender, System.ComponentModel.CancelEventArgs e)
{

	// Reset BackColor the appearance of the cell right before the cell is about
	// to be deactivated.
	this.ultraGrid1.ActiveCell.Appearance.ResetBackColor( );

}
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