Version

SelectionDrag Event

Occurs when the user holds the primary mouse button down over a selected object for a short duration.
Syntax
'Declaration
 
Public Event SelectionDrag As CancelEventHandler
public event CancelEventHandler SelectionDrag
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.

PropertyDescription
Cancel  
Remarks

Since creating a new selection (of rows, columns, cells, etc.) and initiating a drag and drop operation can both be triggered by the same action (the user holding down the primarily mouse button and moving the mouse pointer), this event serves to differentiate between the two.

This event is generated when the user holds the primary mouse button down over a selected object for a short duration before actually moving the mouse pointer. If the mouse pointer is not moved before the duration expires, this event is generated; otherwise, a new selection is created and this event is not generated.

The cancel argument enables you to programmatically restore the selection process, allowing the user to continue the selection action.

The programmer should use this event to implement drag and drop operations.

Example
Following code shows some of the information available in SelectionDrag event.

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
Imports System.Diagnostics

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

       If Me.ultraGrid1.Selected.Rows.Count > 0 Then
           Debug.WriteLine(Me.ultraGrid1.Selected.Rows.Count & " rows are being dragged.")
       ElseIf Me.ultraGrid1.Selected.Cells.Count > 0 Then
           Debug.WriteLine(Me.ultraGrid1.Selected.Cells.Count & " cells are being dragged.")
       ElseIf Me.ultraGrid1.Selected.Columns.Count > 0 Then
           Debug.WriteLine(Me.ultraGrid1.Selected.Columns.Count & " columns are being dragged.")
       End If

       ' You can cancel the drag by canceling the event.
       e.Cancel = True

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

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

	if ( this.ultraGrid1.Selected.Rows.Count > 0 )
	{
		Debug.WriteLine( this.ultraGrid1.Selected.Rows.Count + " rows are being dragged." );
	}
	else if ( this.ultraGrid1.Selected.Cells.Count > 0 )
	{
		Debug.WriteLine( this.ultraGrid1.Selected.Cells.Count + " cells are being dragged." );
	}
	else if ( this.ultraGrid1.Selected.Columns.Count > 0 )
	{
		Debug.WriteLine( this.ultraGrid1.Selected.Columns.Count + " columns are being dragged." );
	}

	// You can cancel the drag by canceling the event.
	e.Cancel = true;

}
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