private void ListBox_DragLeave(object sender, EventArgs e) { tmrLVScroll.Enabled = false; /* * if(DefaultDragLeavebehaviour) * { * //StringBuilder clipData = new StringBuilder(); * if (SelectedItems.Count > 0) * { * tool.TextClipboard.Clear(); * foreach (ListViewItem item in SelectedItems) * { * tool.TextClipboard.Add(item.SubItems[1].Text); * //clipData.AppendLine(item.SubItems[1].Text); * // MusicPlayer.Clipboard.Add(item.SubItems[1].Text); * } * } * * //tool.Show(clipData.ToString()); * * //Clipboard.SetText(clipData.ToString()); * // tool.Show(clipData.ToString()); * //copy selected items to clipboard * } */ if (TotalClipboard.IsEmpty) { if (SelectedItems.Count > 0) { foreach (ListViewItem item in SelectedItems) { TotalClipboard.Add(item.SubItems[1].Text); } TotalClipboard.SourceListBox = this; } } }
protected virtual void ListBox_DragDrop(object sender, DragEventArgs e) { int last = SelectedItems[SelectedItems.Count - 1].Index; ListViewItem[] list = new ListViewItem[SelectedItems.Count]; SelectedItems.CopyTo(list, 0); List <ListViewItem> li = list.ToList(); if (targetItem.Index > last) { li.Reverse(); // list.Reverse(); //MessageBox.Show(list.Length.ToString()); } foreach (ListViewItem lvi in li) { if (targetItem != null) { if (targetItem.Index != lvi.Index) { MoveItem(targetItem.Index, lvi); } } else { MoveItem(this.Items.Count, lvi); } } TotalClipboard.Clear(); // tool.Show(); // tool.Show(); // BoxChanged(this, EventArgs.Empty); tmrLVScroll.Enabled = false; }