DEV treeList 获取 ListcheckBox选中节点内容
Dictionary<string, string> dic = new Dictionary<string, string>(); //用于存储选择内容
/// <summary>
/// 获取选中的节点
/// </summary>
/// <param name="tree"></param>
private void FindSelectChecked(DevExpress.XtraTreeList.TreeList tree, bool dataStatus)
{
this.dic.Clear();
if (tree.Nodes.Count > 0)
{
foreach (TreeListNode root in tree.Nodes)
{
GetCheckedKeyID(root, dataStatus);
}
}
}
/// <summary>
/// 获取选择状态的数据
/// </summary>
/// <param name="parentNode">父级节点</param>
private void GetCheckedKeyID(TreeListNode parentNode, bool dataStatus)
{
if (parentNode.Nodes.Count == 0) return;//递归终止
foreach (TreeListNode node in parentNode.Nodes)
{
if (dataStatus)
{
node.Checked = false;
DataRowView drRow = tvArea.GetDataRecordByNode(node) as DataRowView;
foreach (DataRow row in dtPrecinct.Rows)
{
if (row["DISTRICTS_CODE"].ToString().Trim() == drRow["DISTRICTS_CODE"].ToString().Trim())
{
node.Checked = true;
}
}
}
else
{
if (node.CheckState == CheckState.Checked)
{
DataRowView drv = tvArea.GetDataRecordByNode(node) as DataRowView;
if (drv != null)
{
dic.Add((string)drv["DISTRICTS_CODE"], (string)drv["DISTRICTS_NAME"]);
}
}
}
GetCheckedKeyID(node, dataStatus);
}
}