Version

ISelectionStrategy Interface

ISelectionStrategy is implemented by SelectionStrategyBase class
Syntax
'Declaration
 
Public Interface ISelectionStrategy 
public interface ISelectionStrategy 
Example

The following sample code illustrates how to supply a custom selection strategy for cells in an UltraGridControl.


Note: this is not usually necessary. Normally, the selection strategy for cells is based on the setting of the 'SelectTypeCell' property of the UltraGridOverride object.



Imports Infragistics.Win
    Imports Infragistics.Win.UltraWinGrid


' Implement the ISelectionStrategyFilter interface on a class
' (in this case the form)
Public Class Form1
    Inherits System.Windows.Forms.Form
    Implements Infragistics.Win.ISelectionStrategyFilter

    Private cellSelectionStrategy As MyCustomSelectionStrategy

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        ' Create the custom selection strategy
        Me.cellSelectionStrategy = New MyCustomSelectionStrategy(Me.UltraGrid1)

        ' Set the grid’s SelectionStrategyFilter property to the object that
        ' implements the ISelectionStrategyFilter interface.
        Me.UltraGrid1.SelectionStrategyFilter = Me

    End Sub

    Public Function GetSelectionStrategy(ByVal item As Infragistics.Shared.ISelectableItem) As Infragistics.Win.ISelectionStrategy Implements Infragistics.Win.ISelectionStrategyFilter.GetSelectionStrategy

        ' If the item is a cell return the custom strategy
        If TypeOf (item) Is UltraGridCell Then
            Return Me.cellSelectionStrategy
        End If

        ' Return null to have the grid provide an appropriate strategy
        Return Nothing

    End Function
End Class

' derive a class from one of the selection
' strategies defines in the PLF 
Friend Class MyCustomSelectionStrategy
    Inherits Infragistics.Win.SelectionStrategyExtended

    Public Sub New(ByVal manager As ISelectionManager)

        MyBase.New(manager)

    End Sub

    Public Overloads Overrides Function OnMouseDown(ByVal item As Infragistics.Shared.ISelectableItem, ByRef msginfo As Infragistics.Win.MouseMessageInfo) As Boolean

        ' Do some custom mouse down processing
        ' ...
        Return MyBase.OnMouseDown(item, msginfo)

    End Function
End Class
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 );

		}
	}
}
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