■ 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
using System; using Infragistics.Win.UltraWinDataSource; using Infragistics.Win.UltraWinGrid; private UltraGrid ultraGrid; private UltraDataSource ultraDataSource; private Random random = new Random(); ... #region 폼 로드시 처리하기 - Form_Load(sender, e) /// <summary> /// 폼 로드시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void Form_Load(object sender, EventArgs e) { this.ultraGrid.DataSource = this.ultraDataSource; this.ultraDataSource.Band.Key = "ParentBand"; this.ultraDataSource.Band.Columns.Add("ID" , typeof(int )); this.ultraDataSource.Band.Columns.Add("Col0", typeof(int )); this.ultraDataSource.Band.Columns.Add("Col1", typeof(string)); UltraDataBand childBand = this.ultraDataSource.Band.ChildBands.Add("ChildBand"); childBand.Columns.Add("ChildCol0", typeof(double )); childBand.Columns.Add("ChildCol1", typeof(DateTime)); this.ultraDataSource.Rows.SetCount(100); UltraDataColumn column = this.ultraDataSource.Band.Columns["ID"]; for(int i = 0; i < this.ultraDataSource.Rows.Count; i++ ) { this.ultraDataSource.Rows[i][column] = i; } } #endregion #region UltraDataSource 셀 데이터 요청시 처리하기 - ultraDataSource_CellDataRequested(sender, e) /// <summary> /// UltraDataSource 셀 데이터 요청시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void ultraDataSource_CellDataRequested(object sender, CellDataRequestedEventArgs e) { UltraDataRow row = e.Row; if(e.Column.Band.Key == "ParentBand") { switch(e.Column.Key) { case "Col0" : e.Data = this.random.Next(); break; case "Col1" : e.Data = "String " + this.random.Next(); break; } } else if(e.Column.Band.Key == "ChildBand") { switch(e.Column.Key) { case "ChildCol0" : e.Data = this.random.NextDouble(); break; case "ChildCol1" : e.Data = DateTime.Now.AddDays(this.random.Next(1000)); break; } } e.CacheData = true; } #endregion #region UltraDataSource 행 컬렉션 초기화 하기 - ultraDataSource_InitializeRowsCollection(sender, e) /// <summary> /// UltraDataSource 행 컬렉션 초기화 하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void ultraDataSource_InitializeRowsCollection(object sender, Infragistics.Win.UltraWinDataSource.InitializeRowsCollectionEventArgs e) { if("ChildBand" == e.Rows.Band.Key) { e.Rows.SetCount(10); } } #endregion |