示例#1
0
 private void HacerDragDrop(ListBox lista)
 {
     try
     {
         lista.DoDragDrop(lista.SelectedItem, DragDropEffects.Move);
     }
     catch { }
 }
示例#2
0
        private void ListDragSource_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                // If the mouse moves outside the rectangle, start the drag.
                if (dragBoxFromMouseDown != Rectangle.Empty &&
                    !dragBoxFromMouseDown.Contains(e.X, e.Y))
                {
                    // Create custom cursors for the drag-and-drop operation.
                    try {
                        MyNormalCursor = new Cursor("3dwarro.cur");
                        MyNoDropCursor = new Cursor("3dwno.cur");
                    } catch {
                        // An error occurred while attempting to load the cursors, so use
                        // standard cursors.
                        UseCustomCursorsCheck.Checked = false;
                    }finally {
                        // The screenOffset is used to account for any desktop bands
                        // that may be at the top or left side of the screen when
                        // determining when to cancel the drag drop operation.
                        screenOffset = SystemInformation.WorkingArea.Location;

                        // Proceed with the drag-and-drop, passing in the list item.
                        DragDropEffects dropEffect = ListDragSource.DoDragDrop(ListDragSource.Items[indexOfItemUnderMouseToDrag], DragDropEffects.All | DragDropEffects.Link);

                        // If the drag operation was a move then remove the item.
                        if (dropEffect == DragDropEffects.Move)
                        {
                            ListDragSource.Items.RemoveAt(indexOfItemUnderMouseToDrag);

                            // Selects the previous item in the list as long as the list has an item.
                            if (indexOfItemUnderMouseToDrag > 0)
                            {
                                ListDragSource.SelectedIndex = indexOfItemUnderMouseToDrag - 1;
                            }

                            else if (ListDragSource.Items.Count > 0)
                            {
                                // Selects the first item.
                                ListDragSource.SelectedIndex = 0;
                            }
                        }

                        // Dispose of the cursors since they are no longer needed.
                        if (MyNormalCursor != null)
                        {
                            MyNormalCursor.Dispose();
                        }

                        if (MyNoDropCursor != null)
                        {
                            MyNoDropCursor.Dispose();
                        }
                    }
                }
            }
        }
示例#3
0
 private void HacerDragDrop(ListBox lista, Stack pila)
 {
     try
     {
         torreOrigen = lista;
         pilaOrigen = pila;
         lista.DoDragDrop(lista.SelectedItem, DragDropEffects.Move);
     }
     catch { }
 }
示例#4
0
        private void StartDrop(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (lbfiles.SelectedIndex < 0)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                lbfiles.DoDragDrop((Interfaces.Files.IPackedFileDescriptor)lbfiles.Items[lbfiles.SelectedIndex], DragDropEffects.Copy | DragDropEffects.Link);
            }
        }
示例#5
0
 static void toolboxControl_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (toolboxControl.SelectedItem != null)
         {
             System.Windows.Forms.DataObject obj = new DataObject();
             obj.SetText(toolboxControl.SelectedItem.ToString(), TextDataFormat.UnicodeText);
             obj.SetData(typeof(ScriptEditor).FullName + ".toolbox", toolboxControl);
             toolboxControl.DoDragDrop(obj, DragDropEffects.Copy | DragDropEffects.Move);
         }
     }
 }
示例#6
0
        private void lbDragDropSource_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            int    nSelectedIndex = lbDragDropSource.SelectedIndex;
            string strItem        = (string)lbDragDropSource.Items[nSelectedIndex];

            DragDropEffects dde = lbDragDropSource.DoDragDrop(strItem,
                                                              DragDropEffects.Copy);

            if (DragDropEffects.None == dde)
            {
                MessageBox.Show("Our drag and drop offer was not accepted.");
            }
        }
示例#7
0
 private void listBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     listBox1.DoDragDrop("Hello", DragDropEffects.Move);
 }