noteswiki

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

通过List<String>动态传递参数

 private void GetallChecked_TreeNote(TreeNodeCollection aNodes, ref  int TotalNodeCount, ref  List<string> listItem)
        {

            foreach (TreeNode iNode in aNodes)  
            {

                if (iNode.Nodes.Count == 0 && iNode.Checked==true)
                {
                    richTextBox_tabPage1.AppendText("名称:" + iNode.Name + " | " +
                            "Caption:" + iNode.Text + " | " +
                            "Index:" + iNode.Index.ToString() + "\n");
                    TotalNodeCount = TotalNodeCount + 1;
                    listItem.Add(iNode.Text);
                }
                ;
                if (iNode.Nodes.Count > 0)
                {
                    GetallChecked_TreeNote(iNode.Nodes, ref TotalNodeCount,ref listItem);
                }

            }
        }

 

调用

 private void button2_Click(object sender, EventArgs e)
        {
            int TotalNodeCount;
           
          
            List<string> listItem = new List<string>();
            TotalNodeCount=0;
            richTextBox_tabPage1.AppendText("TotalNode in the treeView1_UserGroup: " + treeView1_UserGroup.GetNodeCount(true).ToString()+"\n");
            if (treeView1_UserGroup.Nodes.Count>0)
            {
                GetallChecked_TreeNote(treeView1_UserGroup.Nodes, ref TotalNodeCount,ref listItem);
            }
            richTextBox_tabPage1.AppendText("Total Selected Nodes : " + TotalNodeCount.ToString() + "\n");
            richTextBox_tabPage1.AppendText("Selected Nodes : " + string.Join(",",listItem.ToArray())+ "\n");
            richTextBox_tabPage1.AppendText("Selected Nodes : " + string.Concat("'", string.Join(",", listItem.ToArray()),"'") + "\n");
            richTextBox_tabPage1.AppendText("Selected Nodes : " + string.Join(",", listItem.Select(x => "'" + x + "'").ToArray()) + "\n");
  }

 

动态 传递给sqlparamter

<略>

posted on 2016-09-08 00:08  noteswiki  阅读(1830)  评论(0编辑  收藏  举报