GiveFeedbackEventArgs 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供拖曳操作期間發生的事件資料 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
- 繼承
- 屬性
範例
以下範例示範兩個 ListBox 控制項之間的拖放操作。 範例中當拖曳動作開始時呼叫該 DoDragDrop 方法。 拖曳動作會開始,前提是滑鼠在事件中SystemInformation.DragSize移動MouseDown超過滑鼠位置。 此 IndexFromPoint 方法用於判定事件中 MouseDown 要拖曳項目的索引。
此範例也會示範如何針對拖放作業使用自定義數據指標。 範例假設應用程式目錄中存在兩個游標檔案, 3dwarro.cur3dwno.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
備註
此 GiveFeedback 事件發生在拖曳操作期間。 它允許拖曳事件的來源修改滑鼠指標的外觀,以便在拖放操作中提供使用者視覺回饋。 物件 GiveFeedbackEventArgs 指定拖放操作的類型,以及是否使用預設游標。
關於事件模型的資訊,請參見 處理與提升事件。
建構函式
| 名稱 | Description |
|---|---|
| GiveFeedbackEventArgs(DragDropEffects, Boolean, Bitmap, Point, Boolean) |
初始化 GiveFeedbackEventArgs 類別的新執行個體。 |
| GiveFeedbackEventArgs(DragDropEffects, Boolean) |
初始化 GiveFeedbackEventArgs 類別的新執行個體。 |
屬性
| 名稱 | Description |
|---|---|
| CursorOffset |
它會讓拖曳影像游標偏移。 |
| DragImage |
取得或設定拖曳影像位圖。 |
| Effect |
會顯示拖放操作的反饋。 |
| UseDefaultCursors |
取得或設定拖曳操作是否應該使用與拖放效果相關的預設游標。 |
| UseDefaultDragImage |
取得或設定一個值,指示是否使用分層視窗拖曳影像。 |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設哈希函式。 (繼承來源 Object) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |