■ 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
using System; using System.Drawing; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; private UltraGrid ultraGrid; private UltraCheckEditor useOSThemeCheckBox; ... #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) { e.Row.ExpandAll(); } #endregion #region Use OS Theme 체크 박스 체크 변경시 처리하기 - useOSThemeCheckBox_CheckedChanged(sender, e) /// <summary> /// Use OS Theme 체크 박스 체크 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void useOSThemeCheckBox_CheckedChanged(object sender, EventArgs e) { if(this.useOSThemeCheckBox.Checked == true) { this.ultraGrid.UseOsThemes = DefaultableBoolean.True; } else { this.ultraGrid.UseOsThemes = DefaultableBoolean.False; } } #endregion #region Grid Header 버튼 클릭시 처리하기 - gridHeaderButton_Click(sender, e) /// <summary> /// Grid Header 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void gridHeaderButton_Click(object sender, EventArgs e) { this.useOSThemeCheckBox.Checked = false; this.ultraGrid.UseOsThemes = DefaultableBoolean.False; this.ultraGrid.Text = "Test Grid"; this.ultraGrid.DisplayLayout.CaptionAppearance.BackColor = Color.LightYellow; } #endregion #region Parent Band Header 버튼 클릭시 처리하기 - parentBandHeaderButton_Click(sender, e) /// <summary> /// Parent Band Header 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void parentBandHeaderButton_Click(object sender, EventArgs e) { this.useOSThemeCheckBox.Checked = false; this.ultraGrid.DisplayLayout.Bands[0].HeaderVisible = true; this.ultraGrid.DisplayLayout.Bands[0].Header.Caption = "Band 0 Header"; this.ultraGrid.DisplayLayout.Bands[0].Header.Appearance.BackColor = Color.LightYellow; } #endregion #region Child Band Header 버튼 클릭시 처리하기 - ChildBandHeaderButton_Click(sender, e) /// <summary> /// Child Band Header 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void ChildBandHeaderButton_Click(object sender, EventArgs e) { this.useOSThemeCheckBox.Checked = false; this.ultraGrid.DisplayLayout.Bands[1].HeaderVisible = true; this.ultraGrid.DisplayLayout.Bands[1].Header.Caption = "Band 1 Header"; this.ultraGrid.DisplayLayout.Bands[1].Header.Appearance.BackColor = Color.LightYellow; } #endregion #region Parent Band Column Header 버튼 클릭시 처리하기 - parentBandColumnHeaderButton_Click(sender, e) /// <summary> /// Parent Band Column Header 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void parentBandColumnHeaderButton_Click(object sender, EventArgs e) { this.useOSThemeCheckBox.Checked = false; this.ultraGrid.DisplayLayout.Bands[0].Override.HeaderAppearance.BackColor = Color.LightYellow; } #endregion #region Child Band Column Header 버튼 클릭시 처리하기 - childBandColumnHeaderButton_Click(sender, e) /// <summary> /// Child Band Column Header 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void childBandColumnHeaderButton_Click(object sender, EventArgs e) { this.useOSThemeCheckBox.Checked = false; this.ultraGrid.DisplayLayout.Bands[1].Override.HeaderAppearance.BackColor = Color.LightYellow; } #endregion #region Order ID Column Header 버튼 클릭시 처리하기 - orderIDColumnHeaderButton_Click(sender, e) /// <summary> /// Order ID Column Header 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void orderIDColumnHeaderButton_Click(object sender, EventArgs e) { this.useOSThemeCheckBox.Checked = false; this.ultraGrid.DisplayLayout.Bands[1].Columns["OrderID"].Header.Caption = "Order ID"; this.ultraGrid.DisplayLayout.Bands[1].Columns["OrderID"].Header.Appearance.BackColor = Color.LightCoral; } #endregion #region Card View Header 버튼 클릭시 처리하기 - cardViewHeaderButton_Click(sender, e) /// <summary> /// Card View Header 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void cardViewHeaderButton_Click(object sender, EventArgs e) { this.useOSThemeCheckBox.Checked = false; this.ultraGrid.DisplayLayout.Bands[1].CardView = true; this.ultraGrid.DisplayLayout.Bands[1].CardSettings.CaptionField = "OrderID"; this.ultraGrid.DisplayLayout.Bands[1].CardSettings.ShowCaption = true; this.ultraGrid.DisplayLayout.Bands[1].Override.CardCaptionAppearance.BackColor = Color.Blue; this.ultraGrid.DisplayLayout.Bands[1].Override.CardCaptionAppearance.ForeColor = Color.White; } #endregion #region Group Header 버튼 클릭시 처리하기 - groupHeaderButton_Click(sender, e) /// <summary> /// Group Header 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void groupHeaderButton_Click(object sender, EventArgs e) { this.useOSThemeCheckBox.Checked = false; if(this.ultraGrid.DisplayLayout.Bands[1].Groups.Exists("Orders") == true) { return; } this.ultraGrid.DisplayLayout.Bands[1].Groups.Add("Orders"); this.ultraGrid.DisplayLayout.Bands[1].LevelCount = 2; this.ultraGrid.DisplayLayout.Bands[1].Columns["CustomerID"].Group = this.ultraGrid.DisplayLayout.Bands[1].Groups["Orders"]; this.ultraGrid.DisplayLayout.Bands[1].Columns["CustomerID"].Level = 0; this.ultraGrid.DisplayLayout.Bands[1].Columns["OrderID"].Group = this.ultraGrid.DisplayLayout.Bands[1].Groups["Orders"]; this.ultraGrid.DisplayLayout.Bands[1].Columns["OrderID"].Level = 0; this.ultraGrid.DisplayLayout.Bands[1].Columns["EmployeeID"].Group = this.ultraGrid.DisplayLayout.Bands[1].Groups["Orders"]; this.ultraGrid.DisplayLayout.Bands[1].Columns["EmployeeID"].Level = 1; this.ultraGrid.DisplayLayout.Bands[1].Columns["OrderDate"].Group = this.ultraGrid.DisplayLayout.Bands[1].Groups["Orders"]; this.ultraGrid.DisplayLayout.Bands[1].Columns["OrderDate"].Level = 1; this.ultraGrid.DisplayLayout.Bands[1].Groups["Orders"].Header.Appearance.BackColor = Color.LightSteelBlue; } #endregion |