예제 #1
0
        /// <summary>
        /// Returns the type of column that is appropriate for the given property of the data source.
        /// Numbers, DateTime, Color and Boolean columns are mapped to NumberColumn, DateTimeColumn, ColorColumn and CheckBoxColumn respectively. The default
        /// is just a TextColumn.
        /// </summary>
        /// <param name="prop"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public virtual Column GetColumn(PropertyDescriptor prop, int index)
        {
            Column column = null;
            switch (prop.PropertyType.Name)
            {
                case "Int32":
                case "Double":
                case "Float":
                case "Int16":
                case "Int64":
                case "Decimal":
                    column = new NumberColumn(prop.Name);
                    break;

                case "DateTime":
                    column = new DateTimeColumn(prop.Name);
                    break;

                case "Color":
                    column = new ColorColumn(prop.Name);
                    break;

                case "Boolean":
                    column = new CheckBoxColumn(prop.Name);
                    break;

                default:
                    column = new TextColumn(prop.Name);
                    break;
            }
            return column;
        }