dragurl

J

James C. Li

Hi,

I've a windows' form application written in C#. I want to
drag a url's link from a website application onto my
windows' form TreeView control. I've been able to achieve
the following

1.) The description of the mouse consor when draging a
TreeNode within the TreeView control using DragOver event.
2.) Draging TreeNode from one Node to another with the
TreeView Control

Actually, the problem I'm facing is for the mouse consor
to indicate object draging effect (DragDropEffects.Move)
instead of indicating unenable object dragging
(DragDropEffects.None)

The events I've used so far are DragItem, DragEnter
(Which I just included from you..Thanks), DragDrop and
DragOver event.

private void treeView1_ItemDrag(object sender,
System.Windows.Forms.ItemDragEventArgs e)
{
DoDragDrop(e.Item, DragDropEffects.Move);
}

private void treeView1_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
}

private void treeView1_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
{
TreeNode NewNode;
Point pt = ((TreeView)sender).PointToClient(new Point
(e.X, e.Y));
TreeNode DestinationNode = ((TreeView)sender).GetNodeAt
(pt);
NewNode = (TreeNode)e.Data.GetData
("System.Windows.Forms.TreeNode");

if(e.Data.GetDataPresent("System.Windows.Forms.TreeNode",
false))
{
if (DestinationNode != null && DestinationNode.Parent !=
NewNode.Parent || DestinationNode.Parent
== NewNode.Parent)
{
DestinationNode.Nodes.Add((TreeNode) NewNode.Clone());
DestinationNode.Expand();
NewNode.Remove();
}
if (e.Data.GetDataPresent(DataFormats.Text))
{
string url = e.Data.GetData(DataFormats.Text).ToString();
DestinationNode.Nodes.Add(url);
}
}
}

private void treeView_DragOver(object sender,
System.Windows.Forms.DragEventArgs e)
{
TreeNode NewNode;
Point pt = ((TreeView)sender).PointToClient(new Point
(e.X, e.Y));
TreeNode DestinationNode = ((TreeView)sender).GetNodeAt
(pt);
NewNode = (TreeNode)e.Data.GetData
("System.Windows.Forms.TreeNode");

if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Move;
}
if(e.Data.GetDataPresent("System.Windows.Forms.TreeNode",
false))
{
if (NewNode == DestinationNode.Parent)
{
e.Effect = DragDropEffects.None;
}
else if ( NewNode.Text == DestinationNode.Text )
{
e.Effect = DragDropEffects.None;
}
else( NewNode.Text == DestinationNode.Text )
{
e.Effect = DragDropEffects.Move;
}


i, I have a windows application written in c#. I want to
drag a url's link from windows explorer onto my
windows' form TreeView control. I've been able to achieve this.



1. Now i want to store the same treeview structure using xml file and
retrieve from the xml file when i open.

2. I have to provide renaming option on right click of any tree node.

3. On double clicking the link i should open the file

can any one help me how to proceed further.

Thanks in advance.
SAYANA
 

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