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