// Event handlers to drag items out of Links Listbox ============================================ private void ListBoxLinks_MouseDown(object sender, MouseEventArgs e) { if (ListBoxLinks.Items.Count == 0) { return; } int index = ListBoxLinks.IndexFromPoint(e.X, e.Y); string s = ListBoxLinks.Items[index].ToString(); DragDropEffects dde1 = DoDragDrop(s, DragDropEffects.All); if (dde1 == DragDropEffects.All) { ListBoxLinks.Items.RemoveAt(ListBoxAssessments.IndexFromPoint(e.X, e.Y)); } }
private void ListBoxAssessments_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.StringFormat)) { // Get string from object (the assessment name) string assessment = (string)e.Data.GetData(DataFormats.StringFormat); // Change text to remove [Linked] int index = ListBoxAssessments.FindString(assessment, -1); if (index > -1) { // Add item ListBoxAssessments.Items.RemoveAt(index); ListBoxAssessments.Items.Insert(index, assessment); } } }
// Drag event handler for Assessments Listbox private void ListBoxAssessments_MouseDown(object sender, MouseEventArgs e) { if (ListBoxAssessments.Items.Count == 0) { return; } int index = ListBoxAssessments.IndexFromPoint(e.X, e.Y); string s = ListBoxAssessments.Items[index].ToString(); // Only allow drag for unlinked items -- Added in 1.3.1 if (!s.Contains("Linked") && (ListBoxLinks.Items.Count == 0)) { DragDropEffects dde1 = DoDragDrop(s, DragDropEffects.All); if (dde1 == DragDropEffects.All) { // Change item to show [Linked] -- Added at 1.3.1 ListBoxAssessments.Items.RemoveAt(index); ListBoxAssessments.Items.Insert(index, s + " --- Linked"); } } }