GiveFeedbackEventArgs 类

定义

为拖动操作期间发生的 GiveFeedback 事件提供数据。

public ref class GiveFeedbackEventArgs : EventArgs
[System.Runtime.InteropServices.ComVisible(true)]
public class GiveFeedbackEventArgs : EventArgs
public class GiveFeedbackEventArgs : EventArgs
[<System.Runtime.InteropServices.ComVisible(true)>]
type GiveFeedbackEventArgs = class
    inherit EventArgs
type GiveFeedbackEventArgs = class
    inherit EventArgs
Public Class GiveFeedbackEventArgs
Inherits EventArgs
继承
GiveFeedbackEventArgs
属性

示例

以下示例演示两个 ListBox 控件之间的拖放操作。 该示例在拖动操作启动时调用 DoDragDrop 方法。 如果鼠标在 MouseDown 事件期间从鼠标位置移动了超过 SystemInformation.DragSize,则拖动操作将启动。 IndexFromPoint 方法用于确定在 MouseDown 事件期间要拖动的项的索引。

该示例还演示如何对拖放操作使用自定义游标。 该示例假定两个游标文件(3dwarro.cur3dwno.cur)分别存在于应用程序目录中,分别用于自定义拖放游标。 如果选中 UseCustomCursorsCheckCheckBox,将使用自定义游标。 自定义游标在 GiveFeedback 事件处理程序中设置。

键盘状态在右侧 ListBoxDragOver 事件处理程序中进行评估,以确定拖动操作将基于 SHIFT、Ctrl、Alt 或 Ctrl+Alt 键的状态。 在 DragOver 事件期间,也会确定 ListBox 发生放置的位置。 如果要删除的数据不是 String,则 DragEventArgs.Effect 设置为 DragDropEffects.None。 最后,删除状态显示在 DropLocationLabelLabel中。

要删除的右 ListBox 的数据在 DragDrop 事件处理程序中确定,并在 ListBox的适当位置添加 String 值。 如果拖动操作在窗体边界之外移动,则拖放操作在 QueryContinueDrag 事件处理程序中取消。

此代码摘录演示了如何使用 GiveFeedbackEventArgs 类。 有关完整的代码示例,请参阅 DoDragDrop 方法。

void ListDragSource_GiveFeedback( Object^ /*sender*/, System::Windows::Forms::GiveFeedbackEventArgs^ e )
{
   // Use custom cursors if the check box is checked.
   if ( UseCustomCursorsCheck->Checked )
   {
      // Sets the custom cursor based upon the effect.
      e->UseDefaultCursors = false;
      if ( (e->Effect & DragDropEffects::Move) == DragDropEffects::Move )
                  ::Cursor::Current = MyNormalCursor;
      else
                  ::Cursor::Current = MyNoDropCursor;
   }
}
private void ListDragSource_GiveFeedback(object sender, GiveFeedbackEventArgs e)
{
    // Use custom cursors if the check box is checked.
    if (UseCustomCursorsCheck.Checked)
    {
        // Sets the custom cursor based upon the effect.
        e.UseDefaultCursors = false;
        if ((e.Effect & DragDropEffects.Move) == DragDropEffects.Move)
            Cursor.Current = MyNormalCursor;
        else
            Cursor.Current = MyNoDropCursor;
    }
}
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

注解

拖动操作期间发生 GiveFeedback 事件。 它允许拖动事件的源修改鼠标指针的外观,以便在拖放操作期间为用户提供视觉反馈。 GiveFeedbackEventArgs 对象指定拖放操作的类型以及是否使用默认游标。

有关事件模型的信息,请参阅 处理和引发事件

构造函数

GiveFeedbackEventArgs(DragDropEffects, Boolean)

初始化 GiveFeedbackEventArgs 类的新实例。

GiveFeedbackEventArgs(DragDropEffects, Boolean, Bitmap, Point, Boolean)

初始化 GiveFeedbackEventArgs 类的新实例。

属性

CursorOffset

获取或设置拖动图像光标偏移量。

DragImage

获取或设置拖动图像位图。

Effect

获取显示的拖放操作反馈。

UseDefaultCursors

获取或设置拖动操作是否应使用与拖放效果关联的默认光标。

UseDefaultDragImage

获取或设置一个值,该值指示是否使用分层窗口拖动图像。

方法

Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于