GiveFeedbackEventArgs.Effect プロパティ

定義

表示されているドラッグ アンド ドロップ操作のフィードバックを取得します。

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 値のいずれか 1 つ。

次の例では、2 つの ListBox コントロール間のドラッグ アンド ドロップ操作を示します。 この例では、ドラッグ アクションの DoDragDrop 開始時に メソッドを呼び出します。 ドラッグ 操作は、イベント中にマウスの位置からマウスが移動 SystemInformation.DragSize した場合に MouseDown 開始されます。 メソッドは IndexFromPoint 、イベント中にドラッグする項目のインデックスを MouseDown 決定するために使用されます。

この例では、ドラッグ アンド ドロップ操作にカスタム カーソルを使用する方法も示します。 この例では、 3dwarro.cur カスタム ドラッグ カーソルと 3dwno.curドロップなしカーソルのそれぞれについて、アプリケーション ディレクトリに 2 つのカーソル ファイル と が存在することを前提としています。 がオンになっている場合 UseCustomCursorsCheckCheckBox は、カスタム カーソルが使用されます。 カスタム カーソルは、イベント ハンドラーで GiveFeedback 設定されます。

キーボードの状態は、右 ListBoxのイベント ハンドラーでDragOver評価され、Shift キー、Ctrl キー、Alt キー、または Ctrl + Alt キーの状態に基づいてドラッグ操作が決定されます。 ドロップが発生する内の ListBox 場所も、イベント中に DragOver 決定されます。 削除するデータが でないStringDragEventArgs.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

適用対象