GiveFeedbackEventArgs.Effect 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取显示的拖放操作反馈。
public:
property System::Windows::Forms::DragDropEffects Effect { System::Windows::Forms::DragDropEffects get(); };
public System.Windows.Forms.DragDropEffects Effect { get; }
member this.Effect : System.Windows.Forms.DragDropEffects
Public ReadOnly Property Effect As DragDropEffects
属性值
其中一个 DragDropEffects 值。
示例
以下示例演示两 ListBox 个控件之间的拖放操作。 该示例在拖动操作启动时调用 DoDragDrop 该方法。 如果鼠标在事件发生期间SystemInformation.DragSize已从鼠标位置移动超过MouseDown鼠标位置,则拖动操作将开始。 该方法 IndexFromPoint 用于确定在事件期间 MouseDown 要拖动的项的索引。
该示例还演示如何对拖放操作使用自定义游标。 该示例假定两个游标文件 3dwarro.cur ,并且 3dwno.cur分别存在于应用程序目录中,用于自定义拖放游标。 如果选中自定义游标, UseCustomCursorsCheckCheckBox 将使用自定义游标。 自定义游标在事件处理程序中 GiveFeedback 设置。
键盘状态在右侧DragOver的事件处理程序中ListBox计算,以确定拖动操作将基于 SHIFT、Ctrl、Alt 或 Ctrl+Alt 键的状态。 在事件发生期间ListBox也会确定放置位置DragOver。 如果要删除的数据不是一个 String,则 DragEventArgs.Effect 设置为 DragDropEffects.None。 最后,下拉列表的状态显示在 DropLocationLabelLabel.
要为右侧 ListBox 删除的数据在事件处理程序中 DragDrop 确定,并在 String 相应的位置 ListBox添加值。 如果拖动操作在窗体的边界外移动,则会在 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