日期:2014-05-17 浏览次数:20951 次
private TreeNode exchangenode = null;
private void treeView1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.AllowedEffect;
if (e.Data.GetDataPresent(typeof(System.Windows.Forms.TreeNode)))
{
e.Effect = DragDropEffects.Copy;
exchangenode = (TreeNode)e.Data.GetData(typeof(System.Windows.Forms.TreeNode));
}
else
e.Effect = DragDropEffects.None;
}
private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)
{
DoDragDrop(e.Item, DragDropEffects.Copy);
}
private void treeView1_DragLeave(object sender, EventArgs e)
{
if (exchangenode != null)
{
treeView1.Nodes.Remove(exchangenode);
}
}
private void treeView2_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.AllowedEffect;
if (e.Data.GetDataPresent(typeof(System.Windows.Forms.TreeNode)))
treeView2.Nodes.Add((TreeNode)e.Data.GetData(typeof(System.Windows.Forms.TreeNode)));
}