Пример #1
0
		public DataGridColumn Add(string property,
		                          string caption,
		                          EditorBase editor)
		{
			SourceGrid.Cells.DataGrid.Cell cell = new SourceGrid.Cells.DataGrid.Cell();
			cell.Editor = editor;

			return Add(property, caption, cell);
		}
Пример #2
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;
        }
Пример #3
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);
        }