Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

UserControl Drag and Drop

djd829djd829 Member Posts: 10
Hello,

I created a UserControl with a listbox in it(along with some other irrelevant controls). I plan to use it on a form with multiple instances, specifically in an array. I want to be able to select one of the items in one instance of the listbox, and drag and drop it onto an item in another instance of the listbox(really two separate UserControls). However, I cannot drop anything outside of the UserControl I started in. DragIcon = null, so it shows the border of the listbox when I drag from it, and the border won't leave the control itself. It's completely self-contained.

Is there anyway around this?

Thanks
Dan

Comments

  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    : Hello,
    :
    : I created a UserControl with a listbox in it(along with some other irrelevant controls). I plan to use it on a form with multiple instances, specifically in an array. I want to be able to select one of the items in one instance of the listbox, and drag and drop it onto an item in another instance of the listbox(really two separate UserControls). However, I cannot drop anything outside of the UserControl I started in. DragIcon = null, so it shows the border of the listbox when I drag from it, and the border won't leave the control itself. It's completely self-contained.
    :
    : Is there anyway around this?
    :
    : Thanks
    : Dan
    :

    I assume you're not using the OLD drag and drop methods? I think you'll have to. With these, it should be fairly simple to work out.

    Good luck,
    KDL
  • djd829djd829 Member Posts: 10
    : : Hello,
    : :
    : : I created a UserControl with a listbox in it(along with some other irrelevant controls). I plan to use it on a form with multiple instances, specifically in an array. I want to be able to select one of the items in one instance of the listbox, and drag and drop it onto an item in another instance of the listbox(really two separate UserControls). However, I cannot drop anything outside of the UserControl I started in. DragIcon = null, so it shows the border of the listbox when I drag from it, and the border won't leave the control itself. It's completely self-contained.
    : :
    : : Is there anyway around this?
    : :
    : : Thanks
    : : Dan
    : :
    :
    : I assume you're not using the OLD drag and drop methods? I think you'll have to. With these, it should be fairly simple to work out.
    :
    : Good luck,
    : KDL
    :

    I'm using MouseDown and MouseMove events to detect a "drag". When it is detected I run the Drag method for the listbox. However it won't let me drag out of the control. Could you please emphasize on "old" drag and drop methods?

    Thanks,
    Dan

  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    : I'm using MouseDown and MouseMove events to detect a "drag". When it is detected I run the Drag method for the listbox. However it won't let me drag out of the control. Could you please emphasize on "old" drag and drop methods?
    :

    I'm sorry, that was a typo; I meant "OLE" drag-n-drop.

    Set the listbox's OLEDragMode to Automatic and it's OLEDropMode to Manual. If a selected item is dragged, the OLE drag will automatically occur. When the item is dragged over/dropped on another control, the OLEDragOver(?) and OLEDragDrop events will occur. In these events, you can set the mouseicon to copy, move or none depending on the data in the DataObject and get your data.

    Drag-n-drop is locked to a single form (I believe a usercontrol is actually a borderless form in disguise).
    OLEDrag-n-drop is system-wide; you can get lists of files dropped on your control from explorer!

    Let me know if you need more info on this.
  • djd829djd829 Member Posts: 10
    : : I'm using MouseDown and MouseMove events to detect a "drag". When it is detected I run the Drag method for the listbox. However it won't let me drag out of the control. Could you please emphasize on "old" drag and drop methods?
    : :
    :
    : I'm sorry, that was a typo; I meant "OLE" drag-n-drop.
    :
    : Set the listbox's OLEDragMode to Automatic and it's OLEDropMode to Manual. If a selected item is dragged, the OLE drag will automatically occur. When the item is dragged over/dropped on another control, the OLEDragOver(?) and OLEDragDrop events will occur. In these events, you can set the mouseicon to copy, move or none depending on the data in the DataObject and get your data.
    :
    : Drag-n-drop is locked to a single form (I believe a usercontrol is actually a borderless form in disguise).
    : OLEDrag-n-drop is system-wide; you can get lists of files dropped on your control from explorer!
    :
    : Let me know if you need more info on this.
    :

    Oh okay :) I had tried OLE Drag and drop, but for some reason it doesn't work right. I tried the manual approach, and the automatic approach. Both tries, it didn't look like it initiated drag and drop.. The cursor will stay an arrow, and when I move it around, it changes the selected item in the list. In fact, I bet if I had multiselect on, it would select a lot of items. What am I doing wrong?
  • djd829djd829 Member Posts: 10
    : : : I'm using MouseDown and MouseMove events to detect a "drag". When it is detected I run the Drag method for the listbox. However it won't let me drag out of the control. Could you please emphasize on "old" drag and drop methods?
    : : :
    : :
    : : I'm sorry, that was a typo; I meant "OLE" drag-n-drop.
    : :
    : : Set the listbox's OLEDragMode to Automatic and it's OLEDropMode to Manual. If a selected item is dragged, the OLE drag will automatically occur. When the item is dragged over/dropped on another control, the OLEDragOver(?) and OLEDragDrop events will occur. In these events, you can set the mouseicon to copy, move or none depending on the data in the DataObject and get your data.
    : :
    : : Drag-n-drop is locked to a single form (I believe a usercontrol is actually a borderless form in disguise).
    : : OLEDrag-n-drop is system-wide; you can get lists of files dropped on your control from explorer!
    : :
    : : Let me know if you need more info on this.
    : :
    :
    : Oh okay :) I had tried OLE Drag and drop, but for some reason it doesn't work right. I tried the manual approach, and the automatic approach. Both tries, it didn't look like it initiated drag and drop.. The cursor will stay an arrow, and when I move it around, it changes the selected item in the list. In fact, I bet if I had multiselect on, it would select a lot of items. What am I doing wrong?
    :
    Nevermind. I'm an idiot. I found that after I run the OLEDrag method, I *have* to change the parameters in the OLEStartDrag event or it will be ignored. It works now, thanks a lot :)

    Dan
  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    : Nevermind. I'm an idiot. I found that after I run the OLEDrag method, I *have* to change the parameters in the OLEStartDrag event or it will be ignored. It works now, thanks a lot :)
    :

    Aye, took me a minute to figure that one out too; I'm used to the automatic mode...
  • djd829djd829 Member Posts: 10
    : : Nevermind. I'm an idiot. I found that after I run the OLEDrag method, I *have* to change the parameters in the OLEStartDrag event or it will be ignored. It works now, thanks a lot :)
    : :
    :
    : Aye, took me a minute to figure that one out too; I'm used to the automatic mode...
    :

    I would have liked to use automode, but it didn't give me the flexibility I required.

    Basically the control looks like a toolbox form. It has a caption(a label), a close button in the corner, and a list box in it. If you've ever used Access, you will see something similar in the query builder, where you have these movable listboxes(each table you open) on the form.
  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    : I would have liked to use automode, but it didn't give me the flexibility I required.
    :

    That's what I thought, so I tested to make sure I knew how manual would work in case you asked.

    Good luck with your app!
    KDL
Sign In or Register to comment.