Hello everyone,
This is a note that continues the saga of implementing drag & drop in a
TreeView (and, presumably, a ListView as well).
When DoDragDrop() is called the framework takes over the business of moving
items around. This much makes perfect sense and is what you would expect it
to do.
A behaviour that has caused me some difficulty is when the DragEffect
reverts to .None for no apparent reason. Of course, there is always a reason
and one of them is when the framework code detects an error. For example, if
a relevant object is null when it shouldn't be, the 'revert to .None'
behaviour is invoked. The client code continues to function in all other
respects and that's fine but no indication of what has gone wrong is given.
True, it's difficult to imagine how the framework code could generate an
appropriate msg about the state of client objects but nevertheless the
programmer is left guessing.
In my case, the target node had not been initialised to a valid TreeNode so
whenever it was referenced some try block somewhere picked it up and an
exception was raised.
Net result: if you observe this behaviour first make sure the data you are
supplying to the process is valid. I know this sounds obvious but things like
this are always obvious AFTER you've spent a couple of days working it out.
Anyway, I hope this is of value to someone out there in TreeViewLand.
--
Kia pai tō haere, e hoa mā!
Nā Plumer