コード例 #1
0
        private void ListBoxLinks_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);

                // If the assesment is not already present then add it to Links list
                int index = ListBoxLinks.FindString(assessment, -1);
                if (index == -1)
                {
                    // Add item
                    ListBoxLinks.Items.Add(assessment);
                }
            }
        }
コード例 #2
0
        // 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));
            }
        }