■ UltraGrid 클래스에서 커스텀 셀을 병합하는 방법을 보여준다.
▶ 예제 코드 (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 |
using System; using Infragistics.Win.UltraWinGrid; #region UltraGrid 레이아웃 초기화 하기 - ultraGrid_InitializeLayout(sender, e) /// <summary> /// UltraGrid 레이아웃 초기화 하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void ultraGrid_InitializeLayout(object sender, InitializeLayoutEventArgs e) { e.Layout.Override.MergedCellStyle = MergedCellStyle.Always; e.Layout.Bands[0].Columns["ShippedDate"].MergedCellEvaluator = new CustomMergedCellEvaluator(); } #endregion ... /// <summary> /// 커스텀 병합 셀 평가자 /// </summary> public class CustomMergedCellEvaluator: IMergedCellEvaluator { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - CustomMergedCellEvaluator() /// <summary> /// 생성자 /// </summary> public CustomMergedCellEvaluator() { } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 셀 병합 여부 구하기 - ShouldCellsBeMerged(ultraGridRow1, ultraGridRow2, ultraGridColumn) /// <summary> /// 셀 병합 여부 구하기 /// </summary> /// <param name="ultraGridRow1">UltraGridRow 1</param> /// <param name="ultraGridRow2">UltraGridRow 2</param> /// <param name="ultraGridColumn">UltraGridColumn</param> /// <returns>셀 병합 여부</returns> public bool ShouldCellsBeMerged(UltraGridRow ultraGridRow1, UltraGridRow ultraGridRow2, UltraGridColumn ultraGridColumn) { object cellValue1 = ultraGridRow1.GetCellValue(ultraGridColumn); object cellValue2 = ultraGridRow2.GetCellValue(ultraGridColumn); if(cellValue1 != DBNull.Value && cellValue2 != DBNull.Value) { DateTime dateTime1 = (DateTime)ultraGridRow1.GetCellValue(ultraGridColumn); DateTime dateTime2 = (DateTime)ultraGridRow2.GetCellValue(ultraGridColumn); return dateTime1.Date == dateTime2.Date; } else { return false; } } #endregion } |