需求:
  一个父窗体,和一个子窗体:
                    父窗体中有一个DataGridview控件,
                    子窗体中,左侧我采用的treeview控件(调用数据库中的一个表a),右侧dataGrideview控件显示treeview控件中节点的条目内容(数据库中另外一个表b)。
  现在,我想通过选中子窗体中的Treeview控件中的某一节点,其节点中的条目内容(在子窗体datagridview控件显示的)能够复制到父窗体中的dataGridview控件中。
  多谢各位!
         
 

解决方案 »

  1.   

    第一步
            void treeView1_MouseDown(object sender, MouseEventArgs e)
            {
                TreeNode tn = treeView1.GetNodeAt(e.X, e.Y);
                if (tn != null)
                {
                    treeView1.SelectedNode = tn;
                    if (tn.Tag is YourTagType)
                    {
                        YourTagTypecd cd= tn.Tag as YourTagType;
                        if ((ModifierKeys == Keys.Control) && (e.Button == MouseButtons.Left))
                        {//按下Control键,然后用鼠标左键拖动,传送cd.ID过去(当然也可以传一个可序列化的对象
                            DoDragDrop(cd.ID, DragDropEffects.Copy);
                        }
                    }
                }
            }第二步:
    实现事件:
            private void OnDragControlEnter(object sender, DragEventArgs e)
            {
                e.Effect = DragDropEffects.All;
            }
     private void OnDragControlDrop(object sender, DragEventArgs e)
    {
    //接收到的数据从e里传过来
    }
      

  2.   

     在拖放的过程中,不是采用的事
    treeview控件的:ItemDrag事件
    放的则是Datagridview控件中的DragDrop,DragEnter
    我不太懂楼上的,
      

  3.   

    楼主看看这个连接吧,讲的很详细
    http://www.cnblogs.com/tuyile006/archive/2006/08/30/490150.html