Drag and drop

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thorpe

    #1

    Drag and drop

    I am currentl writting an c# application but I need a few pointers.

    I want to allow a user to drag an image from the windows desktop to my
    application. I know this is possible with c++ but can this be done in c#. I
    have looked into AllowDrop and dragevents etc but this only allows the
    application to drag things from with in its self

    thanks in advance


  • Jeff Gaines

    #2
    Re: Drag and drop

    On Wed, 22 Oct 2003 16:33:35 +0100, "Thorpe" <p_wyatt@hotmai l.com>
    wrote:
    [color=blue]
    >I am currentl writting an c# application but I need a few pointers.
    >
    >I want to allow a user to drag an image from the windows desktop to my
    >application. I know this is possible with c++ but can this be done in c#. I
    >have looked into AllowDrop and dragevents etc but this only allows the
    >application to drag things from with in its self
    >
    >thanks in advance
    >[/color]

    Have a look at the drop event for the control that the files are being
    dropped on, for a ListView it would be:

    private void lvRIGHT_DragDro p(object sender,
    System.Windows. Forms.DragEvent Args e)

    The parameter DragEventArgs 'e' contains the data you will need and
    you can get at it like this (it may be in other formats depending on
    its source):

    if (e.Data.GetData Present(DataFor mats.FileDrop))
    string[] strFiles = (string[])e.Data.GetData (DataFormats.Fi leDrop);

    This gives you an array of (fully qualified) file names that are being
    dropped. You can then copy/move/create shortcuts etc. I tend to use
    the API for events like that but you could also use native functions.

    --
    Jeff Gaines Damerham Hampshire UK

    Comment

    Working...