Export (0) Print
Expand All

GiveFeedbackEventArgs Class

Provides data for the GiveFeedback event, which occurs during a drag operation.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

'Declaration
<ComVisibleAttribute(True)> _
Public Class GiveFeedbackEventArgs
	Inherits EventArgs
'Usage
Dim instance As GiveFeedbackEventArgs

/** @attribute ComVisibleAttribute(true) */ 
public class GiveFeedbackEventArgs extends EventArgs
ComVisibleAttribute(true) 
public class GiveFeedbackEventArgs extends EventArgs
Not applicable.

The GiveFeedback event occurs during a drag operation. It allows the source of a drag event to modify the appearance of the mouse pointer in order to give the user visual feedback during a drag-and-drop operation. A GiveFeedbackEventArgs object specifies the type of drag-and-drop operation and whether default cursors are used.

For information about the event model, see Events and Delegates.

The following example demonstrates a drag-and-drop operation between two ListBox controls. The example calls the DoDragDrop method when the drag action starts. The drag action starts if the mouse has moved more than SystemInformation.DragSize from the mouse location during the MouseDown event. The IndexFromPoint method is used to determine the index of the item to drag during the MouseDown event.

The example also demonstrates using custom cursors for the drag-and-drop operation. The example assumes that two cursor files, 3dwarro.cur and 3dwno.cur, exist in the application directory, for the custom drag and no-drop cursors, respectively. The custom cursors will be used if the UseCustomCursorsCheckCheckBox is checked. The custom cursors are set in the GiveFeedback event handler.

The keyboard state is evaluated in the DragOver event handler for the right ListBox, to determine what the drag operation will be based upon state of the SHIFT, CTRL, ALT, or CTRL+ALT keys. The location in the ListBox where the drop would occur is also determined during the DragOver event. If the data to drop is not a String, then the DragEventArgs.Effect is set to DragDropEffects.None. Finally, the status of the drop is displayed in the DropLocationLabelLabel.

The data to drop for the right ListBox is determined in the DragDrop event handler and the String value is added at the appropriate place in the ListBox. If the drag operation moves outside the bounds of the form, then the drag-and-drop operation is canceled in the QueryContinueDrag event handler.

This code excerpt demonstrates using the GiveFeedbackEventArgs class. See the DoDragDrop method for the complete code example.

Private Sub ListDragSource_GiveFeedback(ByVal sender As Object, ByVal e As GiveFeedbackEventArgs) Handles ListDragSource.GiveFeedback

    ' Use custom cursors if the check box is checked.
    If (UseCustomCursorsCheck.Checked) Then

        ' Set the custom cursor based upon the effect.
        e.UseDefaultCursors = False
        If ((e.Effect And DragDropEffects.Move) = DragDropEffects.Move) Then
            Cursor.Current = MyNormalCursor
        Else
            Cursor.Current = MyNoDropCursor
        End If
    End If

End Sub

private void listDragSource_GiveFeedback(Object sender, 
    System.Windows.Forms.GiveFeedbackEventArgs e)
{
    // Use custom cursors if the check box is checked.
    if (useCustomCursorsCheck.get_Checked()) {
        // Sets the custom cursor based upon the effect.
        e.set_UseDefaultCursors(false);
        if ((e.get_Effect() & DragDropEffects.Move) 
            == DragDropEffects.Move) {
            get_Cursor().set_Current(myNormalCursor);
        }
        else {
            get_Cursor().set_Current(myNoDropCursor);
        }
    }
} //listDragSource_GiveFeedback

System.Object
   System.EventArgs
    System.Windows.Forms.GiveFeedbackEventArgs

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft