首页  编辑  

文件拖拽

Tags: /C#/文件目录操作/   Date Created:

this. AllowDrop = true ;

protected override void OnDragEnter( DragEventArgs drgevent)

{

    if (drgevent . Data . GetDataPresent( DataFormats . FileDrop))

       drgevent . Effect = DragDropEffects . Copy;

    base . OnDragEnter(drgevent);

}

protected override void OnDragDrop( DragEventArgs drgevent)

{

    if (drgevent . Data . GetDataPresent( DataFormats . FileDrop))

   {

        string [] vFileNames = ( string [])drgevent . Data . GetData(

            DataFormats . FileDrop);

       Text = string . Join( "," , vFileNames);

   }

    base . OnDragDrop(drgevent);

}