Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to handle objects drag-drop? (Excel 2007 + VS 2008)

Hi,

I have Excel 2007 add-in VS 2008 application.

I created Custom Task Pane containing TreeList and would like to drag
TreeList elements and drop them into Excel cell which action would change
cell value.

I guess I neet to handle some Workbook or Application event but cannot find
anything useful.
How do I go about this?

Thanks,

Thomas

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How to handle objects drag-drop? (Excel 2007 + VS 2008)

Hi Thomas,

When you say TreeList do you mean the TreeView Control?

If that was the case, you don't need to do any work on the Excel side, just
handle the TreeView's ItemDrag event, in the event handler, call the
control's DoDragDrop method to start a drag & drop operation, once the item
is being dropped onto a cell, Excel will do its job to get the data you set
in the DoDragDrop method.

Sample code (suppose the TreeView control's name is tvData):

VB.NET

Private Sub tvData_ItemDrag(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ItemDragEventArgs) Handles tvData.ItemDrag
Dim item As TreeNode = TryCast(e.Item, TreeNode)

If (item IsNot Nothing) Then
tvData.DoDragDrop(item.Text, DragDropEffects.Copy)
End If
End Sub

C#

private void tvData_ItemDrag(System.Object sender, ItemDragEventArgs e)
{
TreeNode item = e.Item as TreeNode;

if (item != null)
{
tvData.DoDragDrop(item.Text, DragDropEffects.Copy);
}
}

You can also customize the data before sending it to the DoDragDrop method.

If you have any further questions regarding this issue, please feel free to
post here.

Regards,

Jie Wang , remove 'online.')

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to handle objects drag-drop? (Excel 2007 + VS 2008)

Thanks!
It worked.
TJ
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to handle objects drag-drop? (Excel 2007 + VS 2008)

One more question.

How do I modify code like below

tvData.DoDragDrop("=MyFn(" + item.Text +")", DragDropEffects.Copy)

so my custom function gets pasted and evaluated, rather than just a text?
The problem is not the function (when typed into cell it works) but that
Excel does not evaluate text copied this way as a function.

Tomasz

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How to handle objects drag-drop? (Excel 2007 + VS 2008)

Hi Tomasz,

The following code works on my side:

tvData.DoDragDrop(String.Format("=SayHello(""{0}"" )", item.Text),
DragDropEffects.Copy)

Where SayHello function is defined in VBA.

Drag & drop built-in functions also works:

tvData.DoDragDrop("=TODAY()", DragDropEffects.Copy)

Could you verify the actual string you're sending to drag & drop contains
the correct format of the formular?

Thanks,

Jie



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How to handle objects drag-drop? (Excel 2007 + VS 2008)

Hi Tomasz,

Any updates on this issue?

If there were anything I missed in the formular drag-drop issue, please let
me know and I'll see how to fix it.

Thanks,

Jie Wang , remove 'online.')

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default How to handle objects drag-drop? (Excel 2007 + VS 2008)

Hello Jie Wang,

I'm also trying to handle drag-drop into Excel 2007.
I done the DoDragDrop method and it worked, but i need other thing.

I would like to display a context menu when i drop the value, so it can do
some kind of operation. Is there any event i can handle to do it?

For example:
I'm dragin some values, and when i drop them, i want the following options:
- Convert to Euro
- Convert to Dollar
- ... (Other operations)

Can this be done? (i notice that if i click the right button while dragging
it appear a context menu)

""Jie Wang [MSFT]"" wrote:

Hi Thomas,

When you say TreeList do you mean the TreeView Control?

If that was the case, you don't need to do any work on the Excel side, just
handle the TreeView's ItemDrag event, in the event handler, call the
control's DoDragDrop method to start a drag & drop operation, once the item
is being dropped onto a cell, Excel will do its job to get the data you set
in the DoDragDrop method.

Sample code (suppose the TreeView control's name is tvData):

VB.NET

Private Sub tvData_ItemDrag(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ItemDragEventArgs) Handles tvData.ItemDrag
Dim item As TreeNode = TryCast(e.Item, TreeNode)

If (item IsNot Nothing) Then
tvData.DoDragDrop(item.Text, DragDropEffects.Copy)
End If
End Sub

C#

private void tvData_ItemDrag(System.Object sender, ItemDragEventArgs e)
{
TreeNode item = e.Item as TreeNode;

if (item != null)
{
tvData.DoDragDrop(item.Text, DragDropEffects.Copy);
}
}

You can also customize the data before sending it to the DoDragDrop method.

If you have any further questions regarding this issue, please feel free to
post here.

Regards,

Jie Wang , remove 'online.')

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007: mouse cant find cell handle to drag/move Carl Henthorn Excel Discussion (Misc queries) 4 April 30th 23 03:44 AM
File Move-Drag and Drop Fails in Office 2007 Excel & Word Cole Excel Discussion (Misc queries) 0 March 19th 10 09:32 PM
fill handle and cell drag-and-drop jfh14 Excel Discussion (Misc queries) 1 October 8th 08 08:24 PM
Fill Handle doesn't display - Allow cell drag and Drop option is c Joey Excel Discussion (Misc queries) 1 April 9th 08 09:29 PM
drag and drop objects from outside the workbook to a specific cell? helpwithXL Excel Programming 0 February 24th 05 03:21 PM


All times are GMT +1. The time now is 01:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"