拖动??

gmailee 2007-11-20 10:41:40
请问要把系统的文件名拖动到(treeview, listview)请问在实现。谢谢
...全文
66 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
gmailee 2007-11-20
  • 打赏
  • 举报
回复
大哥啊,你救了我啊。。
soaringbird 2007-11-20
  • 打赏
  • 举报
回复

//参考如下代码
private void textBox1_DragDrop(object sender, DragEventArgs e)
{
Array vFiles = (System.Array)e.Data.GetData(DataFormats.FileDrop);
foreach (object vFile in vFiles)
{
((TextBox)sender).AppendText(vFile.ToString() + "\r\n ");
}
}


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";
}

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧