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); }
private void CreateColumns(SourceGrid.DataGridColumns columns, DevAge.ComponentModel.IBoundList bindList) { 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; //Borders DevAge.Drawing.RectangleBorder border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.ForestGreen), new DevAge.Drawing.BorderLine(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; //Create columns SourceGrid.DataGridColumn gridColumn; gridColumn = dataGrid.Columns.Add(null, "", new SourceGrid.Cells.Link()); gridColumn.DataCell.AddController(new LinkClickDelete()); gridColumn.DataCell.View = viewLink; ((SourceGrid.Cells.Link)gridColumn.DataCell).Image = Properties.Resources.trash.ToBitmap(); gridColumn = dataGrid.Columns.Add("Flag", "Flag", new SourceGrid.Cells.DataGrid.Image()); gridColumn.DataCell.View = viewImage; gridColumn = dataGrid.Columns.Add("Country", "Country", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Uniform", "Uniform", new SourceGrid.Cells.DataGrid.Image()); gridColumn.DataCell.View = viewImage; gridColumn = dataGrid.Columns.Add("Capital", "Capital", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Population", "Population", typeof(decimal)); gridColumn.DataCell.Editor = numericEditor; gridColumn.DataCell.View = viewNumeric; gridColumn = dataGrid.Columns.Add("Surface", "Surface", typeof(decimal)); gridColumn.DataCell.Editor = numericEditor; gridColumn.DataCell.View = viewNumeric; gridColumn = dataGrid.Columns.Add("Languages", "Languages", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Currency", "Currency", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Major Cities", "Major Cities", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("National Holiday", "National Holiday", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Lowest point", "Lowest point", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Highest point", "Highest point", typeof(string)); gridColumn.DataCell.View = viewString; //Create a conditional view foreach (SourceGrid.DataGridColumn col in columns) { SourceGrid.Conditions.ICondition condition = SourceGrid.Conditions.ConditionBuilder.AlternateView(col.DataCell.View, Color.LightGray, Color.Black); col.Conditions.Add(condition); } }
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); }