public static DataGridTableStyle InitializeLogColumns(this ILogFieldProvider stratum, EditableDataGrid grid)
        {
            DataGridTableStyle tblStyle = new DataGridTableStyle();

            tblStyle.MappingName = "Log";

            foreach (LogFieldSetupDO field in stratum.LogFields)
            {
                DataGridTextBoxColumn col = MakeColumn(field.ColumnType);
                col.MappingName = field.Field;
                col.HeaderText  = field.Heading;
                col.Format      = field.Format; // 'C' = currency, 'N' = number (E.G. "N1" means one decimal place), #0.00
                col.FormatInfo  = null;
                col.NullText    = String.Empty; // <- look into this

                if (field.Width == 0.0)
                {
                    col.Width = MeasureTextWidth(grid, field.Heading.Trim()) + 18;//plus 18 to allow for padding
                }
                else
                {
                    col.Width = (int)field.Width;
                }

                tblStyle.GridColumnStyles.Add(col);
            }

            tblStyle.GridColumnStyles.Add(MakeErrorColumn(Screen.PrimaryScreen.WorkingArea.Width));

            grid.TableStyles.Add(tblStyle);

            return(tblStyle);
        }
Beispiel #2
0
        public static List <DataGridViewColumn> MakeLogColumns(this ILogFieldProvider provider)
        {
            List <DataGridViewColumn> columns = new List <DataGridViewColumn>();

            foreach (LogFieldSetupDO field in provider.LogFields)
            {
                var col = MakeColumn(field.ColumnType);
                col.DataPropertyName = field.Field;
                col.HeaderText       = field.Heading;
                col.AutoSizeMode     = DataGridViewAutoSizeColumnMode.AllCells;

                if (!string.IsNullOrEmpty(field.Format))                                // AND field has format
                {
                    col.DefaultCellStyle = new DataGridViewCellStyle()
                    {
                        Format = field.Format
                    };
                }

                columns.Add(col);
            }

            return(columns);
        }