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)

適用於