Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the ColumnModel class with an array of strings
        /// representing TextColumns
        /// </summary>
        /// <param name="columns">An array of strings that represent the Columns of
        /// the ColumnModel</param>
        public ColumnModel(string[] columns)
        {
            if (columns == null)
            {
                throw new ArgumentNullException("columns", "string[] cannot be null");
            }

            this.Init();

            if (columns.Length > 0)
            {
                Column[] cols = new Column[columns.Length];

                for (int i = 0; i < columns.Length; i++)
                {
                    cols[i] = new TextColumn(columns[i]);
                }

                this.Columns.AddRange(cols);
            }
        }
Ejemplo n.º 2
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)
        {
            NumberColumn numCol = null;
            Column       column = null;

            switch (prop.PropertyType.Name)
            {
            case "Int32":
                numCol         = new NumberColumn(prop.Name);
                numCol.Maximum = Int32.MaxValue;
                numCol.Minimum = Int32.MinValue;
                column         = numCol;
                break;

            case "Double":
                numCol         = new NumberColumn(prop.Name);
                numCol.Maximum = Decimal.MaxValue;
                numCol.Minimum = Decimal.MinValue;
                column         = numCol;
                break;

            case "Float":
                numCol         = new NumberColumn(prop.Name);
                numCol.Maximum = Convert.ToDecimal(float.MaxValue);
                numCol.Minimum = Convert.ToDecimal(float.MinValue);
                column         = numCol;
                break;

            case "Int16":
                numCol         = new NumberColumn(prop.Name);
                numCol.Maximum = Int16.MaxValue;
                numCol.Minimum = Int16.MinValue;
                column         = numCol;
                break;

            case "Int64":
                numCol         = new NumberColumn(prop.Name);
                numCol.Maximum = Int64.MaxValue;
                numCol.Minimum = Int64.MinValue;
                column         = numCol;
                break;

            case "Decimal":
                numCol         = new NumberColumn(prop.Name);
                numCol.Maximum = Decimal.MaxValue;
                numCol.Minimum = Decimal.MinValue;
                column         = numCol;
                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);
        }