4个回答
展开全部
#region ===获取指定节点下已选择的值===
/// <summary>
/// 获取指定节点下已选择的值
/// </summary>
/// <param name="Node"></param>
/// <returns></returns>
public static string GetSelectedChildNodeVText(TreeNode Node)
{
string StrChecked = "";
foreach (TreeNode nd in Node.ChildNodes)
{
if (nd.Checked)
{
StrChecked += nd.Text + ",";
}
if (nd.ChildNodes.Count > 0)
{
StrChecked += GetSelectedChildNodeVText(nd);
}
}
StrChecked = StrChecked.TrimStart(',');
return StrChecked;
}
#endregion
#region===获取指定节点下已选择的文本内容===
/// <summary>
/// 获取指定节点下已选择的文本内容
/// </summary>
/// <param name="Node"></param>
/// <returns></returns>
public static string GetSelectedChildNodeVValue(TreeNode Nodes)
{
string StrCheckedValue = "";
foreach (TreeNode nd in Nodes.ChildNodes)
{
if (nd.Checked)
{
StrCheckedValue += nd.Value + ",";
}
if (nd.ChildNodes.Count > 0)
{
StrCheckedValue += GetSelectedChildNodeVValue(nd);
}
}
StrCheckedValue = StrCheckedValue.TrimStart(',');
return StrCheckedValue;
}
#endregion
/// <summary>
/// 获取指定节点下已选择的值
/// </summary>
/// <param name="Node"></param>
/// <returns></returns>
public static string GetSelectedChildNodeVText(TreeNode Node)
{
string StrChecked = "";
foreach (TreeNode nd in Node.ChildNodes)
{
if (nd.Checked)
{
StrChecked += nd.Text + ",";
}
if (nd.ChildNodes.Count > 0)
{
StrChecked += GetSelectedChildNodeVText(nd);
}
}
StrChecked = StrChecked.TrimStart(',');
return StrChecked;
}
#endregion
#region===获取指定节点下已选择的文本内容===
/// <summary>
/// 获取指定节点下已选择的文本内容
/// </summary>
/// <param name="Node"></param>
/// <returns></returns>
public static string GetSelectedChildNodeVValue(TreeNode Nodes)
{
string StrCheckedValue = "";
foreach (TreeNode nd in Nodes.ChildNodes)
{
if (nd.Checked)
{
StrCheckedValue += nd.Value + ",";
}
if (nd.ChildNodes.Count > 0)
{
StrCheckedValue += GetSelectedChildNodeVValue(nd);
}
}
StrCheckedValue = StrCheckedValue.TrimStart(',');
return StrCheckedValue;
}
#endregion
展开全部
这个肯定是要用递归的!!
//在树和树的节点下面递归去找,看有没有等于该ID的节点,有的话就选中
private void getnodes(TreeNode node, string id)
{
//NODE为空的话就直接在树下面找
if (node == null)
{
foreach (TreeNode nodeaa in treeDepts.Nodes)
{
if (nodeaa.Value == id)
{
nodeaa.Checked = true;
break;
}
foreach (TreeNode item in nodeaa.ChildNodes)
{
getnodes(item, id);
}
}
}
//不为空就在传进来的节点下面找
else
{
if (node.Value == id)
{
node.Checked = true;
}
foreach (TreeNode item in node.ChildNodes)
{
getnodes(item, id);
}
}
}
//在树和树的节点下面递归去找,看有没有等于该ID的节点,有的话就选中
private void getnodes(TreeNode node, string id)
{
//NODE为空的话就直接在树下面找
if (node == null)
{
foreach (TreeNode nodeaa in treeDepts.Nodes)
{
if (nodeaa.Value == id)
{
nodeaa.Checked = true;
break;
}
foreach (TreeNode item in nodeaa.ChildNodes)
{
getnodes(item, id);
}
}
}
//不为空就在传进来的节点下面找
else
{
if (node.Value == id)
{
node.Checked = true;
}
foreach (TreeNode item in node.ChildNodes)
{
getnodes(item, id);
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#region ===获取指定节点下已选择的值===
/// <summary>
/// 获取指定节点下已选择的值
/// </summary>
/// <param name="Node"></param>
/// <returns></returns>
public static string GetSelectedChildNodeVText(TreeNode Node)
{
string StrChecked = "";
foreach (TreeNode nd in Node.ChildNodes)
{
if (nd.Checked)
{
StrChecked += nd.Text + ",";
}
if (nd.ChildNodes.Count > 0)
{
StrChecked += GetSelectedChildNodeVText(nd);
}
}
StrChecked = StrChecked.TrimStart(',');
return StrChecked;
}
#endregion
#region===获取指定节点下已选择的文本内容===
/// <summary>
/// 获取指定节点下已选择的文本内容
/// </summary>
/// <param name="Node"></param>
/// <returns></returns>
public static string GetSelectedChildNodeVValue(TreeNode Nodes)
{
string StrCheckedValue = "";
foreach (TreeNode nd in Nodes.ChildNodes)
{
if (nd.Checked)
{
StrCheckedValue += nd.Value + ",";
}
if (nd.ChildNodes.Count > 0)
{
StrCheckedValue += GetSelectedChildNodeVValue(nd);
}
}
StrCheckedValue = StrCheckedValue.TrimStart(',');
return StrCheckedValue;
}
#endregion
/// <summary>
/// 获取指定节点下已选择的值
/// </summary>
/// <param name="Node"></param>
/// <returns></returns>
public static string GetSelectedChildNodeVText(TreeNode Node)
{
string StrChecked = "";
foreach (TreeNode nd in Node.ChildNodes)
{
if (nd.Checked)
{
StrChecked += nd.Text + ",";
}
if (nd.ChildNodes.Count > 0)
{
StrChecked += GetSelectedChildNodeVText(nd);
}
}
StrChecked = StrChecked.TrimStart(',');
return StrChecked;
}
#endregion
#region===获取指定节点下已选择的文本内容===
/// <summary>
/// 获取指定节点下已选择的文本内容
/// </summary>
/// <param name="Node"></param>
/// <returns></returns>
public static string GetSelectedChildNodeVValue(TreeNode Nodes)
{
string StrCheckedValue = "";
foreach (TreeNode nd in Nodes.ChildNodes)
{
if (nd.Checked)
{
StrCheckedValue += nd.Value + ",";
}
if (nd.ChildNodes.Count > 0)
{
StrCheckedValue += GetSelectedChildNodeVValue(nd);
}
}
StrCheckedValue = StrCheckedValue.TrimStart(',');
return StrCheckedValue;
}
#endregion
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
this.treeView1.SelectedNode.Nodes[]数组。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询