Пример #1
0
        private void SetHeaderRow(ColumnHeaderSection header, CellSetting setting)
        {
            HeaderCell chCell;

            if (setting.CellInstance is RowHeaderCell)
            {
                chCell = new CornerHeaderCell();
            }
            else
            {
                chCell = new ColumnHeaderCell();
            }
            //var chCell = new ColumnHeaderCell();
            chCell.Name     = string.Format("lbl{0}", setting.Name);
            chCell.Value    = setting.Caption;
            chCell.Size     = setting.Size;
            chCell.Location = setting.Location;
            var style = new CellStyle()
            {
                TextAlign = MultiRowContentAlignment.MiddleCenter,
                Multiline = MultiRowTriState.False,
                Font      = setting.Font ?? this.Font,
            };

            chCell.Style = style;

            if (chCell is ColumnHeaderCell)
            {
                var h = chCell as ColumnHeaderCell;
                if (this.Sortable)
                {
                    h.SelectionMode = MultiRowSelectionMode.None;
                    h.SortMode      = SortMode.Automatic;
                }
                else
                {
                    h.SortMode = SortMode.NotSortable;
                }

                if (setting.SortDropDown)
                {
                    h.DropDownContextMenuStrip = GetSortDropDownContextMenuStrip();
                }
                if (setting.DropDownList != null)
                {
                    h.DropDownList = setting.DropDownList;
                }
            }

            header.Cells.Add(chCell);
        }
Пример #2
0
        private void SetDetailRow(Row row, CellSetting setting)
        {
            var c = setting.CellInstance;

            if (c == null)
            {
                c = GetTextBoxCell();
            }
            c.Name       = string.Format("cel{0}", setting.Name);
            c.DataField  = setting.DataField;
            c.Size       = setting.Size;
            c.Location   = setting.Location;
            c.ReadOnly   = setting.ReadOnly;
            c.Enabled    = setting.Enabled;
            c.Visible    = setting.Visible;
            c.TabStop    = setting.TabStop;
            c.Selectable = setting.Selectable;
            if (setting.TabIndex > 0)
            {
                c.TabIndex = setting.TabIndex;
            }
            c.Value = setting.Value;
            if (setting.BackColor != Color.Empty)
            {
                c.Style.BackColor = setting.BackColor;
            }
            if (setting.SelectionBackColor != Color.Empty)
            {
                c.Style.SelectionBackColor = setting.SelectionBackColor;
            }
            if (setting.DisableBackColor != Color.Empty)
            {
                c.Style.DisabledBackColor = setting.DisableBackColor;
            }
            if (setting.Border != null)
            {
                c.Style.Border = setting.Border;
            }
            else if (Border != null)
            {
                c.Style.Border = Border;
            }
            if (setting.Font != null)
            {
                c.Style.Font = setting.Font;
            }
            row.Cells.Add(c);
        }