using System.Data;
using Infragistics.Win.Layout;
using Infragistics.Win.UltraWinGrid;
private UltraGrid ultraGrid;
...
#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.InitializeLayout += ultraGrid_InitializeLayout;
this.ultraGrid.DataSource = GetDataTable();
}
#endregion
#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)
{
UltraGrid ultraGrid = sender as UltraGrid;
UltraGridBand ultraGridBand = ultraGrid.DisplayLayout.Bands[0];
ultraGrid.DisplayLayout.Bands[0].RowLayoutStyle = RowLayoutStyle.GroupLayout;
ultraGrid.DisplayLayout.Override.AllowRowLayoutColMoving = GridBagLayoutAllowMoving.AllowAll;
UltraGridGroup personUltraGridGroup = ultraGridBand.Groups.Add("Person", "학생");
UltraGridGroup scoreUltraGridGroup = ultraGridBand.Groups.Add("Score" , "점수");
ultraGridBand.Columns["Name" ].RowLayoutColumnInfo.ParentGroup = personUltraGridGroup;
ultraGridBand.Columns["Sex" ].RowLayoutColumnInfo.ParentGroup = personUltraGridGroup;
ultraGridBand.Columns["Grade" ].RowLayoutColumnInfo.ParentGroup = personUltraGridGroup;
ultraGridBand.Columns["Korean" ].RowLayoutColumnInfo.ParentGroup = scoreUltraGridGroup;
ultraGridBand.Columns["English"].RowLayoutColumnInfo.ParentGroup = scoreUltraGridGroup;
ultraGridBand.Columns["Math" ].RowLayoutColumnInfo.ParentGroup = scoreUltraGridGroup;
ultraGridBand.Columns["Science"].RowLayoutColumnInfo.ParentGroup = scoreUltraGridGroup;
ultraGridBand.Columns["Sequence"].Header.Caption = "순번";
ultraGridBand.Columns["Name" ].Header.Caption = "성명";
ultraGridBand.Columns["Sex" ].Header.Caption = "성별";
ultraGridBand.Columns["Grade" ].Header.Caption = "학년";
ultraGridBand.Columns["Korean" ].Header.Caption = "국어";
ultraGridBand.Columns["English" ].Header.Caption = "영어";
ultraGridBand.Columns["Math" ].Header.Caption = "수학";
ultraGridBand.Columns["Science" ].Header.Caption = "과학";
ultraGridBand.Columns["Sequence"].RowLayoutColumnInfo.OriginX = 0;
ultraGridBand.Columns["Sequence"].RowLayoutColumnInfo.OriginY = 0;
ultraGridBand.Columns["Sequence"].RowLayoutColumnInfo.SpanX = 2;
ultraGridBand.Columns["Sequence"].RowLayoutColumnInfo.SpanY = 4;
personUltraGridGroup.RowLayoutGroupInfo.OriginX = 2;
personUltraGridGroup.RowLayoutGroupInfo.OriginY = 0;
scoreUltraGridGroup.RowLayoutGroupInfo.OriginX = 10;
scoreUltraGridGroup.RowLayoutGroupInfo.OriginY = 0;
}
#endregion
#region 데이터 테이블 구하기 - GetDataTable()
/// <summary>
/// 데이터 테이블 구하기
/// </summary>
/// <returns>데이터 테이블</returns>
private DataTable GetDataTable()
{
DataTable table = new DataTable();
table.Columns.Add("Sequence", typeof(int ));
table.Columns.Add("Name" , typeof(string));
table.Columns.Add("Sex" , typeof(string));
table.Columns.Add("Grade" , typeof(string));
table.Columns.Add("Korean" , typeof(double));
table.Columns.Add("English" , typeof(double));
table.Columns.Add("Math" , typeof(double));
table.Columns.Add("Science" , typeof(double));
table.Rows.Add(1, "홍길동", "남자", "1", 100, 95, 100, 85 );
table.Rows.Add(2, "김철수", "남자", "2", 100, 85, 90 , 95 );
table.Rows.Add(3, "김영희", "여자", "3", 90 , 90, 95 , 100);
table.AcceptChanges();
return table;
}
#endregion