Click here to Skip to main content
15,914,312 members
Home / Discussions / C#
   

C#

 
QuestionC# Algorithm Pin
izakfick12-Dec-05 21:32
izakfick12-Dec-05 21:32 
GeneralRe: C# Algorithm Pin
J4amieC12-Dec-05 21:52
J4amieC12-Dec-05 21:52 
Questionpdf search Pin
TAREQ F ABUZUHRI12-Dec-05 21:20
TAREQ F ABUZUHRI12-Dec-05 21:20 
AnswerRe: pdf search Pin
Polis Pilavas12-Dec-05 23:10
Polis Pilavas12-Dec-05 23:10 
QuestionTreeview (Windows Application) Pin
Mahi.Ragava12-Dec-05 21:19
Mahi.Ragava12-Dec-05 21:19 
AnswerRe: Treeview (Windows Application) Pin
Curtis Schlak.13-Dec-05 3:20
Curtis Schlak.13-Dec-05 3:20 
GeneralRe: Treeview (Windows Application) Pin
Mahi.Ragava13-Dec-05 17:08
Mahi.Ragava13-Dec-05 17:08 
GeneralRe: Treeview (Windows Application) Pin
Curtis Schlak.14-Dec-05 5:24
Curtis Schlak.14-Dec-05 5:24 
This answer details an extremely minimal implementation of what you want. It assumes that you have two TreeViews on your form with names treeView1 and treeView2.
// In your constructor after InitializeComponent()
treeView1.MouseDown += new MouseEventHandler( SourceTreeMD );
treeView1.MouseUp += new MouseEventHandler( SourceTreeMU );
treeView1.MouseLeave += new EventHandler( SourceTreeML );
treeView2.DragDrop += new DragEventHandler( TargetDrop );
treeView2.DragEnter += new DragEventHandler( TargetEnter );
As implementations of the above declared event handlers, you need the following in your form class.
private void SourceTreeMD( object sender, MouseEventArgs mea )
{
  // Remember the node on the mouse down.
  draggedNode = treeView1.GetNodeAt( mea.X, mea.Y );
}

private void SourceTreeMU( object sender, MouseEventArgs mea )
{
  // Forget the node.
  draggedNode = null;
}

private void SourceTreeML( object sender, EventArgs ea )
{
  // Do the drag and drop.
  if( draggedNode != null )
  {
    treeView1.DoDragDrop( draggedNode, DragDropEffects.Move );
  }
}

private void TargetDrop( object sender, DragEventArgs dea )
{
  // Drop the node.
  Point p = treeView2.PointToClient( new Point( dea.X, dea.Y ) );
  TreeNode dropTargetNode = treeView2.GetNodeAt( p );
  TreeNode sourceNode = dea.Data.GetData( typeof( TreeNode ) ) as TreeNode;
  if( dropTargetNode != null && sourceNode != null )
  {
    sourceNode.Remove();
    dropTargetNode.Nodes.Add( sourceNode );
  }
  else if( sourceNode != null )
  {
    sourceNode.Remove();
    treeView2.Nodes.Add( sourceNode );
  }
}

private void TargetEnter( object sender, DragEventArgs dea )
{
  // Notify the target that the drop is good.
  if( dea.Data.GetDataPresent( typeof( TreeNode ) ) )
  {
    dea.Effect = DragDropEffects.Move;
  }
}

// The node getting dragged.
private TreeNode draggedNode;


"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
GeneralRe: Treeview (Windows Application) Pin
Mahi.Ragava14-Dec-05 17:40
Mahi.Ragava14-Dec-05 17:40 
GeneralRe: Treeview (Windows Application) Pin
Curtis Schlak.15-Dec-05 15:17
Curtis Schlak.15-Dec-05 15:17 
GeneralRe: Treeview (Windows Application) Pin
Mahi.Ragava15-Dec-05 17:55
Mahi.Ragava15-Dec-05 17:55 
GeneralRe: Treeview (Windows Application) Pin
Curtis Schlak.16-Dec-05 11:20
Curtis Schlak.16-Dec-05 11:20 
QuestionData chacing... Pin
ayuba asia12-Dec-05 21:17
ayuba asia12-Dec-05 21:17 
QuestionDataGrid row header text Pin
hellamasta12-Dec-05 21:16
hellamasta12-Dec-05 21:16 
QuestionOpen an excel document Pin
ckruger12-Dec-05 20:30
ckruger12-Dec-05 20:30 
AnswerRe: Open an excel document Pin
HakunaMatada12-Dec-05 20:38
HakunaMatada12-Dec-05 20:38 
GeneralRe: Open an excel document Pin
ckruger12-Dec-05 21:13
ckruger12-Dec-05 21:13 
GeneralRe: Open an excel document Pin
HakunaMatada12-Dec-05 23:49
HakunaMatada12-Dec-05 23:49 
AnswerRe: Open an excel document Pin
Polis Pilavas12-Dec-05 23:13
Polis Pilavas12-Dec-05 23:13 
QuestionHow to use PictureBox Events in Datagrid ??? Pin
Abubakarsb12-Dec-05 20:05
Abubakarsb12-Dec-05 20:05 
AnswerRe: How to use PictureBox Events in Datagrid ??? Pin
MarcelErz12-Dec-05 21:30
MarcelErz12-Dec-05 21:30 
GeneralRe: How to use PictureBox Events in Datagrid ??? Pin
Abubakarsb13-Dec-05 6:02
Abubakarsb13-Dec-05 6:02 
QuestionStoring text information in an image Pin
Maqsood Ahmed12-Dec-05 19:58
Maqsood Ahmed12-Dec-05 19:58 
AnswerRe: Storing text information in an image Pin
Vikram A Punathambekar12-Dec-05 21:46
Vikram A Punathambekar12-Dec-05 21:46 
AnswerRe: Storing text information in an image Pin
MarcelErz12-Dec-05 21:48
MarcelErz12-Dec-05 21:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.