■ UltraGrid 클래스에서 IGroupByEvaluator 인터페이스를 사용해 커스텀 행 그룹을 만드는 방법을 보여준다.
▶ UltraGrid 클래스 : IGroupByEvaluator 인터페이스를 사용해 커스텀 행 그룹 만들기 예제 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
using Infragistics.Win; using Infragistics.Win.UltraWinGrid; private UltraGrid ultraGrid2; ... this.ultraGrid.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy; UltraGridColumn productNameColumn = this.ultraGrid.DisplayLayout.Bands[0].Columns["ProductName"]; productNameColumn.GroupByEvaluator = new CustomGroupByEvaluator(); productNameColumn.HiddenWhenGroupBy = DefaultableBoolean.False; this.ultraGrid.DisplayLayout.Bands[0].SortedColumns.Add(productNameColumn, false, true); |
▶ UltraGrid 클래스 : IGroupByEvaluator 인터페이스를 사용해 커스텀 행 그룹 만들기 (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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
using Infragistics.Win.UltraWinGrid; /// <summary> /// 커스텀 GroupBy 평가자 /// </summary> public class CustomGroupByEvaluator : IGroupByEvaluator, IGroupByEvaluatorEx { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public // IGroupByEvaluator #region GroupBy 값 구하기 - GetGroupByValue(groupRow, row) /// <summary> /// GroupBy 값 구하기 /// </summary> /// <param name="groupRow">UltraGridGroupByRow</param> /// <param name="row">UltraGridRow</param> /// <returns>GroupBy 값</returns> public object GetGroupByValue(UltraGridGroupByRow groupRow, UltraGridRow row) { string value; if(groupRow.Value == null) { value = ""; } else { value = groupRow.Value.ToString(); } if(value.Length > 2) { value = value.Substring((value.Length - 2), 2); } return value.ToUpper(); } #endregion // IGroupByEvaluator #region 그룹의 행 포함 여부 구하기 - DoesGroupContainRow(groupRow, row) /// <summary> /// 그룹의 행 포함 여부 구하기 /// </summary> /// <param name="groupRow">UltraGridGroupByRow</param> /// <param name="row">UltraGridRow</param> /// <returns>그룹의 행 포함 여부</returns> public bool DoesGroupContainRow(UltraGridGroupByRow groupRow, UltraGridRow row) { string cellValue = row.Cells[groupRow.Column].Value.ToString(); if(cellValue.Length > 2) { cellValue = cellValue.Substring((cellValue.Length - 2), 2); } return 0 == string.Compare(groupRow.Value.ToString(), cellValue, true); } #endregion // IGroupByEvaluatorEx #region 비교하기 - Compare(cell1, cell2) /// <summary> /// 비교하기 /// </summary> /// <param name="cell1">UltraGridCell</param> /// <param name="cell2">UltraGridCell</param> /// <returns>비교 결과</returns> public int Compare(UltraGridCell cell1, UltraGridCell cell2) { string cell1Value = cell1.Value as string; if(cell1Value.Length > 2) { cell1Value = cell1Value.Substring(0, 2); } string cell2Value = cell2.Value as string; if(cell2Value.Length > 2) { cell2Value = cell2Value.Substring(0, 2); } return cell2Value.CompareTo(cell1Value); } #endregion } |