Please help with Drag and Drop

This is my requirement.

I am allowed to use a DGV (or a List View or some other control that can be used in tabular form).

Then, I have a set of labels/text boxes that are created in runtime according to some data from a DB. Let's say just text tabels.

So I need to drag and drop contents of these run time generated textboxes/labels onto any preferred cell in the DGV (or that any other control). When that is done, I need to be able to delete/destroy the original label as well.

On the other hand, if the user decides to take some data from the DGV and put them back in the original labels, that should also be possible. SO I guess those labels/textboxes need to be put inside of some kind of a control.

But I'm relatively new to C#, so haven't got much of an idea so as to how to do this. I could get text on labels to be copied to another lables, but when I used a DGV I got stuck.
Main reason being, when an item is dragged onto the DGV, there seems to be no event to detect on which cell the mouse is. The Mouse_Enter method works only for simple mouse enter movements - not when dragging.

PLEASE HELP!

Comments

  • : This is my requirement.
    :
    : I am allowed to use a DGV (or a List View or some other control that
    : can be used in tabular form).
    :
    : Then, I have a set of labels/text boxes that are created in runtime
    : according to some data from a DB. Let's say just text tabels.
    :
    : So I need to drag and drop contents of these run time generated
    : textboxes/labels onto any preferred cell in the DGV (or that any
    : other control). When that is done, I need to be able to
    : delete/destroy the original label as well.
    :
    : On the other hand, if the user decides to take some data from the
    : DGV and put them back in the original labels, that should also be
    : possible. SO I guess those labels/textboxes need to be put inside of
    : some kind of a control.
    :
    : But I'm relatively new to C#, so haven't got much of an idea so as
    : to how to do this. I could get text on labels to be copied to
    : another lables, but when I used a DGV I got stuck.
    : Main reason being, when an item is dragged onto the DGV, there seems
    : to be no event to detect on which cell the mouse is. The Mouse_Enter
    : method works only for simple mouse enter movements - not when
    : dragging.
    :
    : PLEASE HELP!
    :

    You want to check out the DragOver, DragEnter, DragOver, DragDrop and DragLeave events of the DataGridView object. [link=http://www.codeproject.com/KB/cpp/DataGridView_Drag-n-Drop.aspx]Here[/link] is a link to an example of some basic drag drop operations using the DataGridView.

    The Label and TextBox objects also have the aforementioned drag/drop events. Use these events rather than trying to implement your own drag/drop logic using the mouse events.
Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion