Reputation: 7193
I am trying to allow/disallow drag&drop on a treeview based on flag in a Tag object. But I can't find the proper event for this (something like BeforeDrag).
I am using C# and winforms, thanks.
Upvotes: 2
Views: 2807
Reputation: 7193
Ralf was right all I had to do was to add a check In the ItemDrag
callback.
private void tree_ItemDrag(object sender, ItemDragEventArgs e)
{
var node = (e.Item as TreeNode).Tag as DataObject;
if(!node.IsFrozen)
DoDragDrop(e.Item, DragDropEffects.Move);
else
MessageBox.Show("Frozen nodes cannot be moved", "Drag & Drop error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Upvotes: 4
Reputation: 21
Try something of the sorts in your drag function:
private void onMouseDownStartDrag(object sender,'insert other necessary parameters here')
{
if (Convert.ToString(sender.tag == "true"));
{
//code that enables dragging the object
}
}
Upvotes: 1