即时通讯使用C#2.0,我创建了一个资源管理器树,我可以将信息从窗口拖入。现在,当我从即时消息使用的树视图拖动时,它执行DoDragDrop(selectedpath, DragDropEffects.Copy);
c#拖放DataObject
当我在我的mainform中捕获事件时,它被列为一个字符串。我能够做这项工作,但我想它来执行同样的方式,它如果我是从我的Windows资源管理器窗口拖动文件如下
Array name = (Array)e.Data.GetData(DataFormats.FileDrop);
// 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);
}
}
我试图做的DoDragDrop(新数据对象(selectedfile),DragDropEffects.Copy)但不起作用。
复制功能至少告诉这家伙为什么你失望投他的问题! – Kukoy 2011-05-20 15:25:06
谢谢。我已经搜索了一个答案,但似乎没有找到它。 – charles 2011-05-20 15:26:17
我看不出有什么理由要降低这个问题。 +1 – 2011-05-20 15:30:17