C1FlexGrid drag and drop files in VB

Posted by: saidnai on 26 February 2021, 1:28 am EST

    • Post Options:
    • Link

    Posted 26 February 2021, 1:28 am EST

    Good Afternoon,

    It will be great if you can please provide a VB sample for C1FlexGrid with drag and drop that shows how to catch the documents Information (Name, Path, etc). to be shown in a cell and saved in DB.

    Best regards

    Said

  • Posted 28 February 2021, 5:37 pm EST - Updated 3 October 2022, 2:22 pm EST

    Hi,

    You can use the DragDrop and DragOver event to achieve this. First, you need to set the DropMode property of the FlexGrid to DropModeEnum.Manual so that the grid fires the standard drag-drop events. Then you can handle the DragOver event and check if a File is being dragged using the GetData method of the IDataObject and then set the DragDropEffect accordingly. You can use the Data property of the DragEventArgs to get the IDataObject.

    Now you can handle the DragDrop event to handle the dropping of data. You can use the GetData method of the IDataObject with DataFormats.FileDrop, it will return a string array containing the path of all the files being dropped. You can then use the FileInfo class to get all the data about the file using the provided file path and set the data according to your requirement in the cells. You can use the Hitest method of the flexgrid to know the cell on which the content was dropped. Please refer to the GIF and sample attached.

    Regards.

    Avnish

    FlexGridDragDrop.zip

  • Posted 13 March 2023, 6:52 pm EST

    Hi Avnish,

    I need to come back to this issue again. The Drag and Drop is running no problem and also i can get all the informations needed.

    The problem or the wish from users is to drag and drop an attachment directly from an Email, this is not working. Is there a way for this?

    Best regards

    Said

  • Posted 13 March 2023, 7:16 pm EST

  • Posted 14 March 2023, 9:02 pm EST

    Hi Said,

    We have attached the updated sample project showing a similar implementation as suggested in the link shared by @Wolfgang. The attached sample project accepts drag-drop of files from File explorer and Outlook email, and the files dropped from the email are stored in the application startup path.

    PS. Thanks a lot for the assist @Wolfgang :slight_smile:

    Attachment: FlexGridDragDrop_updated.zip

    Best Regards,

    Kartik

  • Posted 16 March 2023, 1:09 pm EST

    Dear Kartik,

    I have reworked the C# sample from Wolfgang to VB and it works.

    Also your sample in VB i have tried and It is perfect.

    Thanks to you both for the support

    Said

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels