Version

SelectionStrategyFilter Property

Gets/sets the custom selection strategy filter
Syntax
'Declaration
 
Public Property SelectionStrategyFilter As Infragistics.Win.ISelectionStrategyFilter
public Infragistics.Win.ISelectionStrategyFilter SelectionStrategyFilter {get; set;}
Remarks

The SelectionStrategyFilter property can be used to implement a customized selection strategy.

This is useful in the case where non-standard selection rules are necessary.

An example of this would be allowing selection of multiple items without using the CTRL or SHIFT keys.

Example
This example uses the control's SelectionStrategyFilter property to implement a custom selection strategy for the control that disallows keyboard selection of weekend days.

This example requires that the form on which the control resides implements the ISelectionStrategyFilter interface, i.e.:
Public Class myForm
Inherits System.Windows.Forms.Form
Implements Infragistics.Win.ISelectionStrategyFilter
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports Infragistics.Win.UltraWinSchedule.MonthViewSingle

	'	1. Implement the ISelectionStrategyFilter interface, by returning an instance
	'	of our custom selection strategy class (see below)
   Public Function GetSelectionStrategy(ByVal item As Infragistics.Shared.ISelectableItem) As Infragistics.Win.ISelectionStrategy Implements Infragistics.Win.ISelectionStrategyFilter.GetSelectionStrategy
   	Return New MySelectionStrategy(Me.ultraMonthViewSingle1)
   End Function

	'	2. Set the control's SelectionStrategyFilter property to refer to the form's
	'	implementation of the ISelectionStrategyFilter interface
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Me.ultraMonthViewSingle1.SelectionStrategyFilter = Me
	End Sub

#Region "MySelectionStrategy class"
' Derives from SelectionStrategySingle. Allows single-selection of days via the mouse.
' Allows keyboard selection for weekdays, but not weekends
Public Class MySelectionStrategy
    Inherits Infragistics.Win.SelectionStrategySingle

    Public Sub New(ByVal manager As ISelectionManager)
        MyBase.New(manager)
    End Sub


    ' Handles keyboard processing for the selection strategy. This overridden
    ' version disallows keyboard selection for weekend days.
    Public Overloads Overrides Function ProcessKeyBoardItem(ByVal item As Infragistics.Shared.ISelectableItem, ByVal shift As Boolean, ByVal control As Boolean) As Boolean
        '	Determine what the selectable item is if it is a Day object, we will disallow
        '	keyboard selection for weekend days.
        Dim day As Infragistics.Win.UltraWinSchedule.Day = item
        If (Not day Is Nothing) Then
            '	If the day of the week is Saturday or Sunday, return false,
            '	signifying that the action should not be performed
            If (day.Date.DayOfWeek = System.DayOfWeek.Saturday Or _
                day.Date.DayOfWeek = System.DayOfWeek.Sunday) Then Return False

            '	For all other days of the week, business as usual
            Return MyBase.ProcessKeyBoardItem(item, shift, control)
        End If

    End Function
End Class
#End Region '   "MySelectionStrategy class"
This example requires that the form on which the control resides implements the ISelectionStrategyFilter interface, i.e.:
public class myForm : System.Windows.Forms.Form, Infragistics.Win.ISelectionStrategyFilter
Inherits System.Windows.Forms.Form
Implements Infragistics.Win.ISelectionStrategyFilter
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;
using Infragistics.Win.UltraWinSchedule.MonthViewSingle;
using System.Diagnostics;

	//	1. Implement the ISelectionStrategyFilter interface, by returning an instance
	//	of our custom selection strategy class (see below)
	ISelectionStrategy ISelectionStrategyFilter.GetSelectionStrategy( Infragistics.Shared.ISelectableItem item )
	{
		return new MySelectionStrategy( this.ultraMonthViewSingle1 );
	}

	//	2. Set the control's SelectionStrategyFilter property to refer to the form's
	//	implementation of the ISelectionStrategyFilter interface
	private void button1_Click(object sender, System.EventArgs e)
	{
		this.ultraMonthViewSingle1.SelectionStrategyFilter = this;
	}

	#region MySelectionStrategy class
	/// <summary>
	/// Derives from SelectionStrategySingle. Allows single-selection of days via the mouse.
	/// Allows keyboard selection for weekdays, but not weekends
	/// </summary>
	public class MySelectionStrategy : Infragistics.Win.SelectionStrategySingle
	{
		
		/// <summary>
		/// Creates a new instance of the MySelectionStrategy class
		/// </summary>
		public MySelectionStrategy( ISelectionManager manager ) : base( manager )
		{
		}
		

		/// <summary>
		/// Handles keyboard processing for the selection strategy. This overridden version disallows keyboard selection for weekend days.
		/// </summary>
		/// <param name="item">The selectable item, i.e., a Day object</param>
		/// <param name="shift">True if Shift key is pressed</param>
		/// <param name="control">True if Control key is pressed</param>
		/// <returns>A boolean indicating whether the action was performed successfully</returns>
		public override bool ProcessKeyBoardItem( Infragistics.Shared.ISelectableItem item, bool shift, bool control )
		{
			//	Determine what the selectable item is; if it is a Day object, we will disallow
			//	keyboard selection for weekend days.
			Infragistics.Win.UltraWinSchedule.Day day = item as Infragistics.Win.UltraWinSchedule.Day;
			if ( day != null  )
			{
				//	If the day of the week is Saturday or Sunday, return false,
				//	signifying that the action should not be performed
				if ( day.Date.DayOfWeek == System.DayOfWeek.Saturday ||
					 day.Date.DayOfWeek == System.DayOfWeek.Sunday )
					return false;
			}

			//	For all other days of the week, business as usual
			return base.ProcessKeyBoardItem( item, shift, control );
		}

	}
	#endregion MySelectionStrategy class
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