DevExpress
2015.12.10 09:48
Devexpress TreeList의 unbound 로드로 값을 가져왔을 때 Node update하는 방법
다물칸 주소복사
조회 수 250 추천 수 0 댓글 0
구분 | 팁&트릭 |
---|---|
출처 | 내가작성 |
구글 찾아도 없고 XtraGrid에서도 되는 FocusNode를 통해 업데이트가 TreeList에서는 안된다.
그래서 또 재귀함수인데, 하나의 함수로 되도록 했다.
알아서 짜깁기 하자.
treeNode가 TreeList 콘트롤이다. 최초 호출 할 때는 tree에 기본값 null로 호출한다.
이 함수에서는 최초 부모노드의 값을 비교하기 위함이 아닌 첫번째 자식노드를 비교대상으로 하여 값을 업데이트 하는 함수이다.
모든 노드를 비교하려면 수정이 필요할 것이다.
public void SetCmdToNode(string strPath, string cmd_restart, string cmd_start, string cmd_stop, TreeListNode tree = null) { if (treeNode.Nodes.Count < 0) return; treeNode.BeginUpdate(); if (tree != null) { // Child Node로 들어온것. for (int i = 0; i < tree.Nodes.Count; i++) { // 1단계 Depth만 체크한다. if (tree.Nodes[i]["process_file_path"].ToString() == strPath) { tree.Nodes[i]["restart_cmd"] = cmd_restart; tree.Nodes[i]["start_cmd"] = cmd_start; tree.Nodes[i]["stop_cmd"] = cmd_stop; } } } else { for (int i = 0; i < treeNode.Nodes.Count; i++) { if (treeNode.Nodes[i].HasChildren) SetCmdToNode(strPath, cmd_restart, cmd_start, cmd_stop, treeNode.Nodes[i]); } } treeNode.EndUpdate(); treeNode.Refresh(); }