【WPF】怎样实现Drag&Drop,比如从左边的ListBox里拖放一项到右边某个控件时,把拖动项的Text显示在某一控件上。 怎样实现拖放,比如从左边的ListBox里拖一项到右边某个控件时,把拖动项的Text显示在某一控件上。看了点MSDN,没看懂,所以才问的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void treeView1_ItemDrag(object sender, ItemDragEventArgs e) { TreeNode s = (TreeNode)e.Item; this.treeView1.DoDragDrop(s.Text, DragDropEffects.Move | DragDropEffects.Copy); }//拖拽treeView的项 private void listBox1_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.Text)) e.Effect = DragDropEffects.Move; }//拖拽时鼠标进入listBox private void listBox1_DragDrop(object sender, DragEventArgs e) { this.textBox2.Items.Add(e.Data.GetData(DataFormats.Text).ToString()); e.Effect = DragDropEffects.Move; }//完成拖拽//这是把treeView的拖到listBox//你要的listBox拖到其他差不多//至于显示label.Text = e.Data.GetData(DataFormats.Text).ToString();//listBox还有个支持拖拽的属性AllowDrop要设为True 调用c++编写的dll,程序报错,高分求解,高手进,急!!!!! 使用命名空间,这样做是否对。不好意思我没装VS index.aspx运行错误,请高手指点! c# 两个坐标点之间的斜率 海康威视播放本地文件抓的图片乱码,请帮忙看看时哪里不对 谁有.net 2005下可以使用的日期控件? 强类型的DataSet(ADO.NET)的一个问题 c# 网页数据采集问题 急!请高手帮忙 移动应用开发快速学习方法 sql查詢語句問題 WCF如何实现Liskov替换原则?
{
TreeNode s = (TreeNode)e.Item;
this.treeView1.DoDragDrop(s.Text, DragDropEffects.Move | DragDropEffects.Copy);
}//拖拽treeView的项 private void listBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Move;
}//拖拽时鼠标进入listBox private void listBox1_DragDrop(object sender, DragEventArgs e)
{
this.textBox2.Items.Add(e.Data.GetData(DataFormats.Text).ToString());
e.Effect = DragDropEffects.Move;
}//完成拖拽
//这是把treeView的拖到listBox
//你要的listBox拖到其他差不多
//至于显示label.Text = e.Data.GetData(DataFormats.Text).ToString();//listBox还有个支持拖拽的属性AllowDrop要设为True