GiveFeedbackEventArgs.UseDefaultCursors 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置拖动操作是否应使用与拖放效果关联的默认光标。
public:
property bool UseDefaultCursors { bool get(); void set(bool value); };
public bool UseDefaultCursors { get; set; }
member this.UseDefaultCursors : bool with get, set
Public Property UseDefaultCursors As Boolean
属性值
如果使用默认指针,值为 true
;否则值为 false
。
示例
以下示例演示两 ListBox 个控件之间的拖放操作。 该示例在 DoDragDrop 拖动操作启动时调用 方法。 如果鼠标在事件期间MouseDown从鼠标位置移动了超过SystemInformation.DragSize,则开始拖动操作。 方法 IndexFromPoint 用于确定在事件期间要拖动的项的 MouseDown
索引。
该示例还演示如何使用自定义光标进行拖放操作。 该示例假定应用程序目录中存在两个游标文件 3dwarro.cur
和 3dwno.cur
,分别用于自定义拖放游标和不放置游标。 如果选中 , UseCustomCursorsCheck
CheckBox 将使用自定义游标。 自定义游标在 事件处理程序中 GiveFeedback 设置。
键盘状态在右侧 ListBox
的事件处理程序中DragOver计算,以确定拖动操作将基于 SHIFT、CTRL、ALT 或 Ctrl+Alt 键的状态。 在 事件期间DragOver
,ListBox
还会确定发生下降的位置。 如果要删除的数据不是 , String
则将 DragEventArgs.Effect 设置为 DragDropEffects.None。 最后,删除的状态显示在 中 DropLocationLabel
Label。
要在右侧 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
注解
系统为不同的拖放操作(如移动或复制)提供默认的拖放光标。 如果 UseDefaultCursors 设置为 false
,则事件源负责设置相应的游标。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈