using System.Diagnostics;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
// Implement the ISelectionStrategyFilter interface on a class
// (in this case the form)
public class Form1 :
System.Windows.Forms.Form,
Infragistics.Win.ISelectionStrategyFilter
{
private ISelectionStrategy cellSelectionStrategy;
private void Form1_Load(object sender, System.EventArgs e)
{
// Set the grid’s SelectionStrategyFilter property to the object that
// implements the ISelectionStrategyFilter interface.
this.ultraGrid1.SelectionStrategyFilter = this;
// Create the custom selection strategy
this.cellSelectionStrategy = new MyCustomSelectionStrategy( this.ultraGrid1 );
}
public Infragistics.Win.ISelectionStrategy GetSelectionStrategy(Infragistics.Shared.ISelectableItem item)
{
// If the item is a cell return the custom strategy
if ( item is UltraGridCell )
return this.cellSelectionStrategy;
return null;
}
// derive a class from one of the selection
// strategies defines in the PLF
internal class MyCustomSelectionStrategy
: SelectionStrategyExtended
{
internal MyCustomSelectionStrategy( ISelectionManager manager )
: base( manager )
{
}
public override bool OnMouseDown(Infragistics.Shared.ISelectableItem item, ref Infragistics.Win.MouseMessageInfo msginfo)
{
// Do some custom mouse down processing
// ...
return base.OnMouseDown( item, ref msginfo );
}
}
}