■ GridFormatRule 클래스에서 컬럼에 아이콘 세트 포맷을 적용하는 방법을 보여준다.
▶ MainForm.cs
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 |
using System; using System.Data; using DevExpress.XtraEditors; using DevExpress.XtraGrid; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Fie;d ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 난수 발생기 /// </summary> private Random random = new Random(); #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); FormatConditionIconSetIcon formatConditionIconSetIcon1 = new FormatConditionIconSetIcon(); formatConditionIconSetIcon1.PredefinedName = "Rating4_1.png"; formatConditionIconSetIcon1.Value = 75m; formatConditionIconSetIcon1.ValueComparison = FormatConditionComparisonType.GreaterOrEqual; FormatConditionIconSetIcon formatConditionIconSetIcon2 = new FormatConditionIconSetIcon(); formatConditionIconSetIcon2.PredefinedName = "Rating4_2.png"; formatConditionIconSetIcon2.Value = 50m; formatConditionIconSetIcon2.ValueComparison = FormatConditionComparisonType.GreaterOrEqual; FormatConditionIconSetIcon formatConditionIconSetIcon3 = new FormatConditionIconSetIcon(); formatConditionIconSetIcon3.PredefinedName = "Rating4_3.png"; formatConditionIconSetIcon3.Value = 25m; formatConditionIconSetIcon3.ValueComparison = FormatConditionComparisonType.GreaterOrEqual; FormatConditionIconSetIcon formatConditionIconSetIcon4 = new FormatConditionIconSetIcon(); formatConditionIconSetIcon4.PredefinedName = "Rating4_4.png"; formatConditionIconSetIcon4.Value = 0m; formatConditionIconSetIcon4.ValueComparison = FormatConditionComparisonType.GreaterOrEqual; FormatConditionIconSet formatConditionIconSet = new FormatConditionIconSet(); formatConditionIconSet.Name = "4등급"; formatConditionIconSet.CategoryName = "등급"; formatConditionIconSet.ValueType = FormatConditionValueType.Number; formatConditionIconSet.Icons.Add(formatConditionIconSetIcon1); formatConditionIconSet.Icons.Add(formatConditionIconSetIcon2); formatConditionIconSet.Icons.Add(formatConditionIconSetIcon3); formatConditionIconSet.Icons.Add(formatConditionIconSetIcon4); FormatConditionRuleIconSet formatConditionRuleIconSet = new FormatConditionRuleIconSet(); formatConditionRuleIconSet.IconSet = formatConditionIconSet; GridFormatRule gridFormatRule = new GridFormatRule(); gridFormatRule.Name = "규칙1"; gridFormatRule.Column = this.scoreColumn; gridFormatRule.Rule = formatConditionRuleIconSet; this.gridView.FormatRules.Add(gridFormatRule); this.gridControl.DataSource = CreateSampleTable(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 샘플 테이블 생성하기 - CreateSampleTable() /// <summary> /// 샘플 테이블 생성하기 /// </summary> /// <returns>샘플 테이블</returns> private DataTable CreateSampleTable() { DataTable table = new DataTable(); table.Columns.Add("ID" , typeof(string)); table.Columns.Add("Name" , typeof(string)); table.Columns.Add("Sex" , typeof(string)); table.Columns.Add("Score", typeof(int )); for(int i = 1; i <= 100; i++) { table.Rows.Add ( string.Format("{0:d3}", i), string.Format("직원 {0:d3}", i), i % 2 == 0 ? "남" : "여", this.random.Next(100) ); } return table; } #endregion } } |