DataFormats.Bitmap


L

LoSTMaN

Hi,

Did someone have a idea why this code always return False when i drag a
filename.bmp in my PictureBox.

Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e As
DragEventArgs) Handles PictureBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.Bitmap) Then ============>>>
Here, always return false
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub


Thank you.
 
Ad

Advertisements

A

Armin Zingler

LoSTMaN said:
Hi,

Did someone have a idea why this code always return False when i
drag a
filename.bmp in my PictureBox.

Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e
As DragEventArgs) Handles PictureBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
============>>>
Here, always return false
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub


A file is dragged (DataFormats.FileDrop), not a bitmap. For example, if you
make a screenshot, DataFormats.Bitmap is an available format in the
clipboard.

Use
Debug.WriteLine(String.Join(vbCrLf, e.Data.GetFormats))
to display the available data formats.

(or Clipboard.GetDataObject.GetFormats instead of e.Data.GetFormats for the
clipboard)


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top