GoToolDragging: add string [] data

I am trying to allow dragging from GoView to other components of my program that are not GoViews. In order to do that I want to add additional “System.String[]” data to the DataObject, whenever I start dragging. I guess I have to do that in GoToolDraging, but I don’t know how.
Thanks in advance for any help.

Well, the general answer is that you can override GoToolDragging.DoDragDrop to specify all the data formats you want.
I suppose you could call GoView.CreateDataObject to return a DataObject that you can pass to GoView.DoDragDrop. Read the documentation for GoView.CreateDataObject for more details.

Thanks for the quick response, but I am still having problems understanding this (I am using GoExpress and there is no documentation on CreateDataObject…)
I tried overriding CreateDataObject, which worked. So far so good, but it is only called for Clipboard operations, not dragging…
So how can I keep regular Clipboard functionality and only use the custom CreateDataObject to be passed to DoDragDrop? And how do I actually PASS the object?
Could you maybe show me some example code.

Sorry, I didn’t mean to imply you needed to override GoView.CreateDataObject. I was just suggesting that its functionality, which as you say is only used when copying to the clipboard, might be useful to you. Assuming its addition of a textual data format were what you wanted, then you could do something like the following, which I have not even tried to compile.
To install a new mouse tool:
goView1.ReplaceMouseTool(typeof(GoToolDragging), new CustomDraggingTool(goView1));
To define a new replacement dragging tool:
public class CustomDraggingTool : GoToolDragging {
public CustomDraggingTool(GoView view) : base(view) {}
public override void DoDragDrop(IGoCollection coll, DragDropEffects allow) {
this.View.DoDragDrop(this.View.CreateDataObject(coll), allow);
Of course you can create your own DataObject instead of calling GoView.CreateDataObject, so you can get the data the way you want it.

O.K. I got it ‘sort of’ working… The custom data gets added and I can access it, if I drag out of the view.
What is not working now is, that I lost the wonderful drag preview I used to have when draging to another GoView .
The cursor just changes to the regular square with the little plus sign.
It seems that GoView now takes string[] to be the primary format… any idea how to fix this?
Here is the code I used so far:
public class MyBasicDraggingTool : GoToolDragging {
public MyBasicDraggingTool(GoView v) : base(v) {
public override void DoDragDrop ( Northwoods.Go.IGoCollection coll ,
System.Windows.Forms.DragDropEffects allow ){
DiagramWrapper dView = (DiagramWrapper) this.View; //my custom GoView
GoDocument clipdoc = new GoDocument(); //create copy of collection
dView.DoDragDrop(dView.myCreateDataO bject(coll, clipdoc),allow);

with ‘myCreateDataObject’ adding the custom data in string[] format

public DataObject myCreateDataObject ( Northwoods.Go.IGoCollection coll ,
Northwoods.Go.GoDocument clipdoc ){
DataObject data = base.CreateDataObject(coll,clipdoc); //get standard GoView DataObject e.g. used for Clipboard
data.SetData(“System.String[]”, this.getSelectedPieceGuids()); //add my custom data
return data;

I’m not sure, but try not creating a GoDocument and copying the collection into it. Try using the GoView’s document instead.
Since drag-and-drop is a modal operation, a copy isn’t needed.
Furthermore, using a generic GoDocument might be causing the problem, since the DataFormat might be different for your view’s document class (but I’m just guessing here, since you didn’t provide that information).