I have the following DataGrid
of name gridOperations
. I have set AllowDrop
to true, and used the following code:
private void gridOperations_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (var filePath in files)
{
MessageBox.Show(filePath);
}
}
}
private void gridOperations_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
but when I try to drag file into the DataGrid
, it gives me the 'STOP' cursor. What am I doing wrong?
Is is possible because it's binded to List?
Basically what I need is to get the filename from file dragged into the datagrid and determinate in which cell its dragged into.
Are your grid and all the parent controls enabled?
Your code is correct and it works. The only thing I can think of is that your GridView may not be enabled. Can you change the current row of the grid by clicking when the application is running?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With