Syntax

Event Data

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

Property

Description

Cancel

Gets or sets a value indicating whether the event should be canceled.

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.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
PrivateSub UltraGrid1_BeforeCellActivate(ByVal sender AsObject, 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 SubPrivateSub UltraGrid1_BeforeCellDeactivate(ByVal sender AsObject, 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

C#

Copy Code

using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;
privatevoid 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;
}
privatevoid 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( );
}

Remarks

Thecancelargument enables you to programmatically prevent the the cell from deactivating, meaning it will not lose focus. This argument can be used to prevent the user from leaving the cell unless a certain condition is met.

This event is generated when the user attempts to move to a different cell, deactivating the original cell.

TheBeforeCellActivateevent is generated before a cell is activated, which means it will get focus.

TheActiveCellproperty can be used to determine which cell is currently active.