通过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
<略>
时间: 2024-10-12 23:21:51