■ 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 |
using System.Data; using System.Drawing; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; private UltraGrid ultraGrid; ... this.ultraGrid.InitializeRow += ultraGrid_InitializeRow; this.ultraGrid.DataSource = GetDataTable(); ... #region UltraGrid 행 초기화 하기 - ultraGrid_InitializeRow(sender, e) /// <summary> /// UltraGrid 행 초기화 하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void ultraGrid_InitializeRow(object sender, InitializeRowEventArgs e) { DefaultEditorOwnerSettings defaultEditorOwnerSettings = new DefaultEditorOwnerSettings(); DefaultEditorOwner defaultEditorOwner = new DefaultEditorOwner(defaultEditorOwnerSettings); EmbeddableEditorBase embeddableEditorBase = null; object cellValue = e.Row.Cells[0].Value; if(cellValue is bool) { defaultEditorOwnerSettings.DataType = typeof(bool); embeddableEditorBase = new CheckEditor(defaultEditorOwner); } else if(cellValue is Color) { defaultEditorOwnerSettings.DataType = typeof(Color); embeddableEditorBase = new ColorPickerEditor(defaultEditorOwner); } else if(cellValue is string) { defaultEditorOwnerSettings.DataType = typeof(string); embeddableEditorBase = new EditorWithText(defaultEditorOwner); } e.Row.Cells[0].Editor = embeddableEditorBase; } #endregion #region 데이터 테이블 구하기 - GetDataTable() /// <summary> /// 데이터 테이블 구하기 /// </summary> /// <returns>데이터 테이블</returns> private DataTable GetDataTable() { DataTable table = new DataTable(); table.Columns.Add("test", typeof(object)); table.Rows.Add(new object[] { Color.Red }); table.Rows.Add(new object[] { false }); table.Rows.Add(new object[] { "Hello" }); table.Rows.Add(new object[] { Color.Blue }); table.Rows.Add(new object[] { true }); table.Rows.Add(new object[] { "Goodbye" }); return table; } #endregion |