473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

dragurl

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.Tre eNode",
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.Tre eNode",
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
Nov 13 '05 #1
1 4755
Sorry for the typo for the wrong address. Please ignore this.

James

"James C. Li" wrote:

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.Tre eNode",
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.Tre eNode",
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

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.