By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,673 Members | 1,268 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,673 IT Pros & Developers. It's quick & easy.

dragurl

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.