DragDrop using using Visio ActiveX Control

S

Steve Cox

I have an application that has a tree view control in it that i am using to
drag-drop text shapes onto the visio control.

It will work if I have 2 instances of the application and drag from one
application to the other.

It will not work if I try to drag from my treeview control to the Visio
Control all in the same application.
 
C

Chris Roth

Are you placing the text of the node into the DragDropEffect?

Dim dde As DragDropEffects = _tree.DoDragDrop( node.Text,
DragDropEffects.Copy)

Here's a sample from stuff I wrote that drops a master that is stored with
the Tag of a treenode:
Private Sub theTreeView_ItemDrag(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemDragEventArgs) Handles theTreeView.ItemDrag

' Get a treenode object:
If Not (TypeOf e.Item Is TreeNode) Then Exit Sub

Dim node As TreeNode = CType(e.Item, TreeNode)
' Get the Visio master object from it's tag, if it
' has one:

If Not (TypeOf node.Tag Is Visio.Master) Then Exit Sub

Dim visMaster As Visio.Master = CType(node.Tag, Visio.Master)
Dim dde As DragDropEffects = _tree.DoDragDrop(visMaster,
DragDropEffects.Copy)

End Sub
--


Hope this helps,

Chris Roth
Visio MVP
visioguy @ extremely warm mail.com
 
S

Steve Cox

Chris,

This is what I am doing in the treeview:


Private Sub TreeView1_ItemDrag(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemDragEventArgs) Handles TreeView1.ItemDrag

Dim strItem As String
Dim item As TreeNode

item = e.Item
If Not (item.Parent Is Nothing) Then
If Not (item.Parent.Parent Is Nothing) Then
Dim o As DataObject
strItem = item.Parent.Text + ":" + item.Text
o = New DataObject(strItem)
DoDragDrop(o, DragDropEffects.Copy)
End If
End If
End Sub

As you see I am using a DataObject. This seems to work from one application
to the other, but not from within a single application. I will look into
the Visio.Master approach. Thanks.
 
S

Steve Cox

Chris,

I have a treeview with text in it. I don't have a real Visio Shape attached
to it. I cannot create a new Visio.Master object.

I can use drag and drop from tree view to some other control, but using the
DragEnter and DragDrop events. I have tested it by dropping onto a text
box, but those events are not available on the Visio Control. It does
however accept Drag and Drop from another application.
 
C

Chris Roth

Have you tried just putting the text in the drag-drop? Visio doesn't seem to
understand your DataObject:

DoDragDrop( strItem , DragDropEffects.Copy )

- Chris.
 
S

Steve Cox

That's what I started with.

The Visio control accepts the drag and drop as long as it isn't in the same
application.

Also if i start visio as an application then drag from my tree view to it,
it works.

It seems to be related to the fact that the Visio Active X control is
resident in the same app as the source of the drag and drop.
 
M

Markus Breugst

Hi Steve,

is there perhaps a difference concerning the type of drop operation that
Visio tries to perform? Example: You allow the copy operation. But perhaps,
if drag and drop are performed within the same application, Visio may try to
do something else, such as move or link? You could try to allow every
operation by specifying
DragDropEffects.All | DragDropEffects.Link as allowed effects. (Just an
idea, I don't know if that helps.)

Regards,
Markus
 
S

Steve Cox

Does anyone from Microsoft have anything to add? Does anyone have any
samples of this working?

As I've stated before, it seems to be an issue with Drag and Drop from a
control in the same application as the Visio ActiveX control.
 

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