treelist 的DoubleClick事件该怎么写?要实现双击就把值传递到下一个窗体。

解决方案 »

  1.   

    有以下几种方法:
    1.新窗体构造函数加上参数
    2.新窗体加个公共属性在form.show()之前进行赋值
      

  2.   

    首先要获取treelist双击时的node,再把相关值传送
    如:
       treelistNode node=treelist.FocusedNode;
        form2 s=new form(node.getValue().tostring());
        s.show();
      

  3.   

    我是这样做的
    public delegate void TreelistDoubleClick();
    public TreelistDoubleClick m_TreelistDoubleClick;        private void treeList1_DoubleClick(object sender, EventArgs e)
            {
                if (m_TreelistDoubleClick != null)
                    m_TreelistDoubleClick();
                MessageBox.Show("DoubleClick");
                //treelistNode node = treelist1.FocusedNode;
                //textEdit1.Text = node.getValue().tostring();
                //form2 s = new form(node.getValue().tostring());
                //s.show();
            }
      

  4.   

    你的form2的构造函数需要修改public partial class form2: Form
    {
        string parmvalue;
        public form2(string nodevalue)
        {
                InitializeComponent();
                 parmvalue = nodevalue
         }
    }
      

  5.   

    上面的上了一个;在这句parmvalue = nodevalue;
      

  6.   

    就是:treelistNode node=treelist.FocusedNode;  这句出错了、!
      

  7.   

    public delegate void TreelistDoubleClick(); 
    public TreelistDoubleClick m_TreelistDoubleClick;         private void treeList1_DoubleClick(object sender, EventArgs e) 
            { 
                if (m_TreelistDoubleClick != null) 
                    m_TreelistDoubleClick(); 
                MessageBox.Show("DoubleClick"); 
                //treelistNode node = treelist1.FocusedNode; 
                textEdit1.Text = this.treeList1.FocusedNode.GetValue("字段名").ToString();
                //form2 s = new form(node.getValue().tostring()); 
                //s.show(); 
            }
      

  8.   

    是不是出现null值了.你自己捕获一下当前点击的是哪个节点啊.
    上面我只是举下例子而已point p=treelist1.PointToClient(mousePostion);
    treelistInfo info=treelist1.calInfo(p);
    treelistnode node=info.node;
    if(node!=null)
     form2 s=new form2(node.getvalues("列值").tostring());
    s.show();