この記事は翻訳者によって翻訳されたものです。 記事の文章にポインターを重ねると、原文のテキストが表示されます。
訳文
原文
このトピックはまだ評価されていません - このトピックを評価する

Control.DragDrop イベント

ドラッグ アンド ドロップ操作が完了したときに発生します。

名前空間:  System.Windows.Forms
アセンブリ:  System.Windows.Forms (System.Windows.Forms.dll 内)
public event DragEventHandler DragDrop

DragEventArgsX プロパティおよび Y プロパティは、クライアント座標ではなく、画面座標の値です。 次の Visual C# のコードでは、これらのプロパティをクライアントの Point に変換します。

Point clientPoint = targetControl.PointToClient(new Point(de.X, de.Y));
メモメモ

.NET Framework Version 2.0 より前のバージョンでは、DragEnter イベントと DragDrop イベントを備えた UserControl を Windows フォーム上に配置し、デザイン時にその UserControl に対して、なんらかのデータをドラッグ アンド ドロップした場合、DropDrop イベントと DropEnter イベントが発生します。 ただし、ソリューションを一度閉じてから再び開くと、DragEnter イベントと DragDrop イベントは発生しなくなります。

イベント処理の詳細については、「イベントの利用」を参照してください。

DragDrop イベントの使用方法を次のコード例に示します。 コード例全体については、DoDragDrop メソッドのトピックを参照してください。


private void ListDragTarget_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) 
{
    // Ensure that the list item index is contained in the data.
    if (e.Data.GetDataPresent(typeof(System.String))) {

        Object item = (object)e.Data.GetData(typeof(System.String));

        // Perform drag-and-drop, depending upon the effect.
        if (e.Effect == DragDropEffects.Copy ||
            e.Effect == DragDropEffects.Move) {

            // Insert the item.
            if (indexOfItemUnderMouseToDrop != ListBox.NoMatches)
                ListDragTarget.Items.Insert(indexOfItemUnderMouseToDrop, item);
            else
                ListDragTarget.Items.Add(item);

        }
    }
    // Reset the label text.
    DropLocationLabel.Text = "None";
}


.NET Framework

サポート対象: 4、3.5、3.0、2.0、1.1、1.0

.NET Framework Client Profile

サポート対象: 4、3.5 SP1

Windows 7, Windows Vista SP1 以降, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core はサポート対象外), Windows Server 2008 R2 (SP1 以降で Server Core をサポート), Windows Server 2003 SP2

.NET Framework では、各プラットフォームのすべてのバージョンはサポートしていません。 サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
この情報は役に立ちましたか。
(残り 1500 文字)
コミュニティ コンテンツ 追加
注釈 FAQ