DragDrop

  • Thread starter Thread starter Lou
  • Start date Start date
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());

}
 
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
 
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
 
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
 
Back
Top