Ejemplo n.º 1
0
        public static Cells.ICellVirtual Create(Type type, bool editable)
        {
            Cells.ICellVirtual cell;

            if (type == typeof(bool))
                cell = new SourceGrid.Cells.DataGrid.CheckBox();
            else
            {
                cell = new SourceGrid.Cells.DataGrid.Cell();
                cell.Editor = SourceGrid.Cells.Editors.Factory.Create(type);
            }

            if (cell.Editor != null) //Can be null for special DataType like Object
            {
                //The columns now support always DbNull values because the validation is done at row level by the DataTable itself.
                cell.Editor.AllowNull = true;
                cell.Editor.EnableEdit = editable;
            }

            return cell;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a DataGridColumn class with the appropriate cells based on the type of the column.
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="dataColumn"></param>
        /// <param name="editable"></param>
        /// <returns></returns>
        public static DataGridColumn Create(DataGrid grid, System.Data.DataColumn dataColumn, bool editable)
        {
            SourceGrid.Cells.ICellVirtual cell;
            if (dataColumn.DataType == typeof(bool))
            {
                cell = new SourceGrid.Cells.DataGrid.CheckBox(dataColumn);
            }
            else
            {
                cell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
                cell.Editor = SourceGrid.Cells.Editors.Factory.Create(dataColumn.DataType);
            }

            if (cell.Editor != null)             //Can be null for special DataType like Object
            {
                //cell.Editor.AllowNull = dataColumn.AllowDBNull;
                cell.Editor.AllowNull  = true;                //The columns now support always DbNull values because the validation is done at row level by the DataTable itself.
                cell.Editor.EnableEdit = editable;
            }

            return(Create(grid, dataColumn, dataColumn.Caption, cell));
        }
Ejemplo n.º 3
0
        public static Cells.ICellVirtual Create(Type type, bool editable)
        {
            Cells.ICellVirtual cell;

            if (type == typeof(bool))
            {
                cell = new SourceGrid.Cells.DataGrid.CheckBox();
            }
            else
            {
                cell        = new SourceGrid.Cells.DataGrid.Cell();
                cell.Editor = SourceGrid.Cells.Editors.Factory.Create(type);
            }

            if (cell.Editor != null) //Can be null for special DataType like Object
            {
                //The columns now support always DbNull values because the validation is done at row level by the DataTable itself.
                cell.Editor.AllowNull  = true;
                cell.Editor.EnableEdit = editable;
            }

            return(cell);
        }
Ejemplo n.º 4
0
        private static void CreateColumns(SourceGrid.DataGridColumns columns, DataTable sourceTable)
        {
            SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(decimal));
            numericEditor.TypeConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(decimal), "N");
            numericEditor.AllowNull     = true;          //the database value can be null (System.DbNull)
            SourceGrid.Cells.Editors.TextBox  stringEditor     = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            SourceGrid.Cells.Editors.ComboBox externalIdEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(int));
            externalIdEditor.StandardValues          = new int[] { 1, 2, 3, 4 };
            externalIdEditor.StandardValuesExclusive = true;
            DevAge.ComponentModel.Validator.ValueMapping mapping = new DevAge.ComponentModel.Validator.ValueMapping();
            mapping.ValueList            = new int[] { 1, 2, 3, 4 };
            mapping.SpecialType          = typeof(string);
            mapping.SpecialList          = new string[] { "Reference 1", "Reference 2", "Reference 3", "Reference 4" };
            mapping.ThrowErrorIfNotFound = false;
            mapping.BindValidator(externalIdEditor);


            DataColumn dataColumn;

            SourceGrid.DataGridColumn     gridColumn;
            SourceGrid.Cells.ICellVirtual dataCell;

            //Create columns

            dataColumn = sourceTable.Columns["Selected"];
            dataCell   = new SourceGrid.Cells.DataGrid.CheckBox(dataColumn);
            gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Country"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.Editor = stringEditor;
            gridColumn      = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn = sourceTable.Columns["Uniform"];
            dataCell   = new SourceGrid.Cells.DataGrid.Image(dataColumn);
            gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Population"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.Editor = numericEditor;
            gridColumn      = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Surface"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.Editor = numericEditor;
            gridColumn      = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["ExternalID"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.Editor = externalIdEditor;
            gridColumn      = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            gridColumn = new MyDataGridColumnStar(columns.Grid, "Star");
            columns.Insert(columns.Count, gridColumn);
        }