TreeList获取TreeListNode绑定的数据

来源:互联网 发布:php开源考试系统 编辑:程序博客网 时间:2024/06/08 04:02
DevExpress控件中的TreeList如果是绑定数据源方式绑定的数据,如何获取选定节点上面包含的数据呢?
 如下方法即可
TreeListNode selectNode = this.treeList1.Selection[0]; DataRowView nodeData = this.treeList1.GetDataRecordByNode(selectNode) as DataRowView; int attachID =Convert.ToInt32( nodeData["id"]);
private string GetNodeFullPathMessage(TreeListNode _focusedNode)        {            string _sCurrentNodeMessage = string.Empty;            if (_focusedNode != null)            {                try                {                    _sCurrentNodeMessage = _focusedNode.GetDisplayText("Name");                    while (_focusedNode.ParentNode != null)                    {                        _focusedNode = _focusedNode.ParentNode;                        _sCurrentNodeMessage = string.Format("{0}-{1}", _focusedNode.GetDisplayText("Name").Trim(), _sCurrentNodeMessage);                    }                }                catch                {                    return string.Empty;                }            }            return _sCurrentNodeMessage;        }

0 0
原创粉丝点击