Group: Forum Members
Last Active: 12 Years Ago
Posts: 9,
Visits: 1
|
I am using the following code to handle a drag drop of a windows explorer file.
public Form1() { InitializeComponent();
treeList.AllowDrop = true; treeList.DragEnter += treeList_DragEnter; treeList.DragDrop += treeList_DragDrop; }
private void treeList_DragDrop(object sender, DragEventArgs e) { string[] files = (string[]) e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { FileInfo info = new FileInfo(file); treeList.Nodes.Add(new NTreeListNode { SubItems = { new NTreeListNodeStringSubItem(info.Name) {Column = treeList.Columns["Name"]}, new NTreeListNodeStringSubItem(info.Length.ToString()) {Column = treeList.Columns["Size"]} } }); } }
private void treeList_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; }
Dragging files to the NTreeList control does not show the Copy cursor, even though the DragEnter handler is called. The DragDrop handler is not called.
Similar code works for Microsoft's ListView.
|