How can I add a custom class to a DragItem?

I’ve got a listbox with celltags containing custom classes and I want to drag the class from its cell to a canvas and perform some drawing based on the class’s properties. Actually, I want to add that class to an array of like classes and the array is defined as a property of the canvas.

First, this doesn’t seem to work (Where “myapp.Skill” is my custom class):


Second, even if that worked, how can I drag myapp.Skill from the listbox?

There was an article on RBlibrary (bought up by xDev magazine) about making a drag and drop interface for your app. Should be available from xDev.

Thanks! Anyone know what issue?

You need to pickle the data at one end and do the unpickling on the other side. Json perhaps or a simple dictionary might work.

In my app the dragged rows are emails which live in a database and have a recid. So the drag gets the recids and puts it into the raw data of the drag.

dim DragRecIDs as string = "('" + Join(theRecIDs, "','") + "')" drag.RawData("MAXX") = DragRecIDs

In the drop object event I have (a bit simplified):

if obj.RawDataAvailable("MAXX") and .. then dim theRecIDs as String = obj.RawData("MAXX") theRecIDs = DefineEncoding(theRecIDs, Encodings.UTF8) dim theSQL as string = "update ...... where RecID in " + theRecIDs call theDatabase.SqlExecute theSQL end if

It’s not in any issue. RBlibrary has a number of separate publications, from articles to books.

You could just drag the rowindex, lookup the celltag when dropped and add to array for processing

I usually try to serialize the data in a custom class. The serialized data I can be passed as RawData. I have a simple method inside that class to do that kind of stuff, accompanied by a deserialize method.

Last year I made some kind of class that looks through all the properties through introspection. I subclassed this class to customize it and take full advantage of the (de)serialize methods. This data-class helps me also to get data from a class to store it somewhere, like preferences, or data received from HTTP sockets.
Additionally, I made methods to store the data to a database and populate a Recordset or DatabaseRecord.

It works like a charm and is very versatile.

If you use UUIDs for your data; you could simply store the data path and UUID on the clipboard. Then when the user pastes, you use the path to get back to the parent object of the original data and the UUID to get that data.

i.e. UUID could be the rowIndex of a database table, and the path could be the table name.