■ TreeList 클래스의 CompareNodeValues 이벤트를 사용해 커스텀 정렬을 적용하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
using DevExpress.XtraGrid; using DevExpress.XtraTreeList; ... private TreeList treeList; ... this.treeList.CompareNodeValues += treeList_CompareNodeValues; this.treeList.Columns["Budget"].SortMode = ColumnSortMode.Custom; ... #region 트리 리스트 노드 값들 비교하기 - treeList_CompareNodeValues(sender, e) /// <summary> /// 트리 리스트 노드 값들 비교하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void treeList_CompareNodeValues(object sender, CompareNodeValuesEventArgs e) { if(e.Column.Caption != "Budget") { return; } try { int value1 = Convert.ToInt32(e.NodeValue1); int value2 = Convert.ToInt32(e.NodeValue2); e.Result = value1 - value2; } catch { } } #endregion |