0

i use windows form to create Dektop Appliction in csharp.

i want to make my PictureBox allow to drag and drop just for custom files like just photos.

so i want to look cursor allowdrop in photos files and prevent in other files.

kareem alkoul
  • 739
  • 6
  • 13
  • 1
    Look [here](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/walkthrough-performing-a-drag-and-drop-operation-in-windows-forms?view=netframeworkdesktop-4.8). – Robert Harvey Jun 02 '22 at 14:08
  • and [here](https://www.codemag.com/article/0407031/Enable-Your-Windows-Forms-Applications-to-Drag-and-Drop-Data-Objects). – Robert Harvey Jun 02 '22 at 14:09
  • First, you have to set the `AllowDrop` property of your PictureBox in code, since it's hidden. Then, when you receive a DataObject that has the `FileDrop` format, get the first file, get its bytes, try to convert it to Image (`new ImageConverter().ConvertFrom([bytes])`). If it fails, it's not an image file or a supported Image format. – Jimi Jun 02 '22 at 14:10

0 Answers0