473,327 Members | 2,016 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,327 software developers and data experts.

Drag and Drop / What object type?

How can I tell what object type is dropped onto my control? Here is a
snippet of code.

private void lvwTasks_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

//I want to know if e.Data is of type MyClass1 or MyClass2

Core.MyClass1 aTask = new MyClass1 ();

aTask = (Core.VariableMapping.MapXMLTask)e.Data.GetData(aT ask.GetType());

Core.MyClass2 aTask2 = new MyClass2 ();

aTask2 = (Core.VariableMapping.MapXMLTask)e.Data.GetData(aT ask2 .GetType());

}
Nov 16 '05 #1
2 5155
APG
MFRASER wrote:
How can I tell what object type is dropped onto my control? Here is a
snippet of code.

private void lvwTasks_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

//I want to know if e.Data is of type MyClass1 or MyClass2

Core.MyClass1 aTask = new MyClass1 ();

aTask = (Core.VariableMapping.MapXMLTask)e.Data.GetData(aT ask.GetType());

Core.MyClass2 aTask2 = new MyClass2 ();

aTask2 = (Core.VariableMapping.MapXMLTask)e.Data.GetData(aT ask2 .GetType());

}

Hi,

You check for null after the e.Data.GetData(). If it is null, the
dropped item is not of that type.

Like:

private void tabPage1_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
Panel pnl =e.Data.GetData(typeof(Panel)) as Panel;
if(pnl == null)
{
//Dropped item is not a panel
}
else
{
//Dropped item is a panel
//Do appropriate action
//Return
}
PictureBox picBox =e.Data.GetData(typeof(PictureBox)) as PictureBox;
if(picBox == null)
{
//Dropped item is not a picture box
//Do appropriate action here
}
}

HTH,
APG
Nov 16 '05 #2

Thank you. I ended up using the DataPresent Method to test the type of
the data.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3

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

Similar topics

9
by: Wang, Jay | last post by:
Hello, all, I would like to enable some text between <SPAN url="http://www.testserver.com/">WORD TO BE DRAGGED </SPAN>. I put some javascript and it will extract http://www.testserver.com/ from...
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
6
by: James Allen Bressem | last post by:
I was searching through the MSDN documentation trying to figure out how to do drag n drop and I found a sample program. The sample program did all sorts of fancy junk like dynamically create it's...
1
by: Thi | last post by:
Hi, I am trying to develop an application that allows the users to drag a few file(s) from a zip archive to a destination. My question is, how do i determine where the drop destination is...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.