共用方式為


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 事件處理程式中,且 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

備註

拖曳作業期間發生 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)

適用於