Beispiel #1
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);
        }
Beispiel #2
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;
            SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            //Borders
            DevAge.Drawing.RectangleBorder border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.Border(Color.ForestGreen), new DevAge.Drawing.Border(Color.ForestGreen));

            //Standard Views
            SourceGrid.Cells.Views.Link viewLink = new SourceGrid.Cells.Views.Link();
            viewLink.BackColor      = Color.DarkSeaGreen;
            viewLink.Border         = border;
            viewLink.ImageAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            viewLink.TextAlignment  = DevAge.Drawing.ContentAlignment.MiddleCenter;
            SourceGrid.Cells.Views.Cell viewString = new SourceGrid.Cells.Views.Cell();
            viewString.BackColor     = Color.DarkSeaGreen;
            viewString.Border        = border;
            viewString.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft;
            SourceGrid.Cells.Views.Cell viewNumeric = new SourceGrid.Cells.Views.Cell();
            viewNumeric.BackColor     = Color.DarkSeaGreen;
            viewNumeric.Border        = border;
            viewNumeric.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight;
            SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell();
            viewImage.BackColor      = Color.DarkSeaGreen;
            viewImage.Border         = border;
            viewImage.ImageStretch   = false;
            viewImage.ImageAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

            Color alternateColor = Color.LightGray;

            DataColumn dataColumn;
            DataGridColumnAlternate gridColumn;

            SourceGrid.Cells.ICellVirtual dataCell;

            //Create columns

            dataCell = new SourceGrid.Cells.Link("");
            dataCell.AddController(new LinkClickDelete());
            dataCell.View = viewLink;
            ((SourceGrid.Cells.Link)dataCell).Image = Properties.Resources.trash.ToBitmap();
            gridColumn = new DataGridColumnAlternate(columns.Grid, null, "Delete", dataCell, alternateColor);
            columns.Insert(columns.Count, gridColumn);
            //Add an image to the header

            dataColumn    = sourceTable.Columns["Flag"];
            dataCell      = new SourceGrid.Cells.DataGrid.Image(dataColumn);
            dataCell.View = viewImage;
            gridColumn    = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor);
            columns.Insert(columns.Count, gridColumn);

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

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

            dataColumn      = sourceTable.Columns["Capital"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.View   = viewString;
            dataCell.Editor = stringEditor;
            gridColumn      = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor);
            columns.Insert(columns.Count, gridColumn);

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

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

            dataColumn      = sourceTable.Columns["Languages"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.View   = viewString;
            dataCell.Editor = stringEditor;
            gridColumn      = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Currency"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.View   = viewString;
            dataCell.Editor = stringEditor;
            gridColumn      = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Major Cities"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.View   = viewString;
            dataCell.Editor = stringEditor;
            gridColumn      = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["National Holiday"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.View   = viewString;
            dataCell.Editor = stringEditor;
            gridColumn      = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Lowest point"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.View   = viewString;
            dataCell.Editor = stringEditor;
            gridColumn      = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Highest point"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.View   = viewString;
            dataCell.Editor = stringEditor;
            gridColumn      = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor);
            columns.Insert(columns.Count, gridColumn);
        }