DragDrop

L

Lou

I have been trying to do something very simple for days now. I'm very
frustrated.

The following VB6 code works beautifully but how do I achieve the same in C#
It a drop target

Private Sub Text2_OLEDragDrop(Data As DataObject, Effect As Long, Button As
Integer, Shift As Integer, X As Single, Y As Single)
MyFormat = RegisterClipboardFormat("CF_MOSCtrlData")
Dim a() As Byte
a = Data.GetData(MyFormat)

MsgBox a
End Sub

I've tried for 2 days to get this to work in C# but can't
private void lstItems_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

// Creates a new data format.

DataFormats.Format myFormat = DataFormats.GetFormat("CF_MOSCtrlData");

if (e.Data.GetDataPresent("CF_MOSCtrlData"))

{

//I get to here so I know there is data, BUT WHERE IS THE DATA?????? HOW DO
I GET THE DATA??????

Object item = (object)e.Data.GetData("CF_MOSCtrlData");

lstItems.Items.Add (item.ToString());

}
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Lou,
I just came up with something that I think you should be aware of.
IDataObject interface provided by .NET platform is not the same IDataObject
interface you may know from COM.

You cannot retreive any data from the DataObject that need FROMATETC's
lIndex member set for example.
Thus, not all data put in the clipboard or dropped over by a not-.NET
applications can be consumed in .NET applications
 
R

Rami Saad

If you are happy with your VB6 code, you can make it compatible with VS.Net
using "RegAsm.exe" too found in the VS.Net folder
 
L

Lou

what do you mean?


Rami Saad said:
If you are happy with your VB6 code, you can make it compatible with VS.Net
using "RegAsm.exe" too found in the VS.Net folder

--
Rami Saad
Microsoft GTSC Developer support for Middle East


in
 

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