473,321 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

DragDrop

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());

}
Nov 15 '05 #1
3 3180
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

--
B\rgds
100

"Lou" <lo********@comcast.net> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
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());

}

Nov 15 '05 #2
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
"Lou" <lo********@comcast.net> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
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());

}

Nov 15 '05 #3
Lou
what do you mean?
"Rami Saad" <ra*******@egdsc.microsoft.com> wrote in message
news:OG**************@TK2MSFTNGP09.phx.gbl...
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
"Lou" <lo********@comcast.net> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
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());

}


Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Kate | last post by:
Hi: I have a form with a picture box and some command buttons to make certain shapes appear in the picture box. The shapes are drawn on blank UserControls added like this: 'at top of form...
10
by: KS | last post by:
I have a Button I want to pull to a Label. I want the Button visualy to move when I pull it. When I drop the button on the Label I want to test some data coming with the Button - f.ex is the...
1
by: KS | last post by:
In want to visualy drag a Button to a Label and when I depress the mousebutton on top of the label I want to show some dato from the Button in a MsgBox - that's my primary goal. I have made a...
2
by: dave | last post by:
I am wishing to drag something from the desktop to a tab of a tab control in vb.net. The dragdrop event fires when release the mouse above the tab however i am having a hard time trying to figure...
0
by: Eric St-Onge | last post by:
Hi, I need to dragdrop message items from Outlook (2002 and 2003) to my application. I successfully implemented DragDrop from Explorer to MyApp but I didnt find how to properly code...
0
by: Flack | last post by:
Hello, Is it possible to find out how many methods are listening to a certain event? For example, if a number of methods subscribed to a controls DragDrop event using +=, can I find out how many...
0
by: Gene Hubert | last post by:
Well, it seems fundamental to me anyway. Hopefully it is simple enough. The question is for when the source for the dragdrop is a different application that the target for the dragdrop. How...
3
by: Gary Dunne | last post by:
I'm writing an app that requires drag and drop operation between a ListView and a TreeView control. (The source is the ListView). During the drag drop operation I want to be able to detect the...
7
by: JohnR | last post by:
I am using dragdrop to drag and drop a custom class instance. When I drag/drop from one window to another window in the same application everything works fine. But when trying to move between the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.