using System;
using System.Drawing;
using System.Windows.Forms;
public class TestForm : Form
{
public TestForm()
{
var treeView = new TreeView()
{
Dock = DockStyle.Left
};
treeView.ItemDrag += (o, e) =>
{
var effect = DragDropEffects.None;
if (e.Button == MouseButtons.Left)
effect = DragDropEffects.Move;
else if (e.Button == MouseButtons.Right)
effect = DragDropEffects.Copy;
DoDragDrop(e.Item, effect);
};
var listView = new ListView()
{
AllowDrop = true,
Dock = DockStyle.Fill
};
listView.DragEnter += (o, e) => e.Effect = e.AllowedEffect;
for (int x = 0; x < 3; ++x)
{
var node = treeView.Nodes.Add(String.Format("Node{0}", x * 4));
for (int y = 1; y < 4; ++y)
node = node.Nodes.Add(String.Format("Node{0}", x * 4 + y));
}
this.SuspendLayout();
this.ClientSize = new Size(400, 300);
this.Controls.Add(treeView);
this.Controls.Add(listView);
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.Run(new TestForm());
}
}