protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i < this.TreeView1.Nodes.Count; i++)//迴圈根節點 { if (TreeView1.Nodes[i].Checke
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.TreeView1.Nodes.Count; i++)//迴圈根節點
{
if (TreeView1.Nodes[i].Checked == false)//判斷是否被選中
{
TreeView1.Nodes[i].Checked = true;
for (int j = 0; j < this.TreeView1.Nodes[i].ChildNodes.Count; j++)//迴圈當前節點的第一級子節點
{
if (this.TreeView1.Nodes[i].ChildNodes[j].Checked == false)
{
TreeView1.Nodes[i].ChildNodes[j].Checked = true;
}
}
}
}
}