示例#1
0
        public TreeListColumn AddColumn(string fieldName, string caption, HorzAlignment align, FormatType formatType, string formatString, bool visible, bool readOnly, int width)
        {
            try
            {
                if (string.IsNullOrEmpty(caption))
                {
                    caption = DomainUtils.GetFieldName(fieldName.ToUpper()).Trim().Replace(" ", string.Empty);
                }
                var col = AddColumn();

                col.Name = "COL_" + fieldName.ToUpper();
                col.AppearanceCell.Options.UseTextOptions = true;
                col.AppearanceCell.TextOptions.HAlignment = align;
                col.Caption = caption;
                col.CustomizationCaption = caption;
                col.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
                col.FieldName = fieldName;

                col.Format.FormatType = formatType;
                if (!string.IsNullOrEmpty(formatString))
                {
                    col.Format.FormatString = formatString;
                }

                if (Editable == false || readOnly)
                {
                    col.OptionsColumn.ReadOnly   = true;
                    col.OptionsColumn.AllowEdit  = false;
                    col.OptionsColumn.AllowFocus = false;
                }
                else
                {
                    col.OptionsColumn.ReadOnly   = false;
                    col.OptionsColumn.AllowEdit  = true;
                    col.OptionsColumn.AllowFocus = true;
                }

                if (width > 0)
                {
                    col.OptionsColumn.AllowSize = false;
                    col.Width = width;
                }
                col.Visible = visible;
                if (visible)
                {
                    col.VisibleIndex = Columns.Count;
                }
                return(col);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
示例#2
0
        private void SetFieldNames(LayoutControl control)
        {
            try
            {
                if (control.Items.Count > 0)
                {
                    foreach (var item in control.Items)
                    {
                        if (item.GetType() == typeof(LayoutControlItem) &&
                            ((LayoutControlItem)item).Name.ToLower().Contains("lcitem"))
                        {
                            ((LayoutControlItem)item).AppearanceItemCaption.TextOptions.HAlignment = HorzAlignment.Far;
                            ((LayoutControlItem)item).AppearanceItemCaption.TextOptions.VAlignment = VertAlignment.Center;

                            var itemName = ((LayoutControlItem)item).Name.Replace("lcItem", string.Empty);
                            itemName = StringUtils.ToUpperUnderscoreByPattern(itemName);

                            var itemText = DomainUtils.GetFieldName(itemName);
                            if (string.IsNullOrEmpty(itemText))
                            {
                                itemText = itemName.Replace("_", " ");
                            }
                            if (((LayoutControlItem)item).Tag != null && ((LayoutControlItem)item).Tag.GetType() == typeof(bool) && (bool)((LayoutControlItem)item).Tag == true)
                            {
                                ((LayoutControlItem)item).Text = string.Format("*{0}:", itemText);
                                ((LayoutControlItem)item).AppearanceItemCaption.ForeColor            = (SkinUtils.IsDarkSkin) ? Color.Yellow : Color.Red;
                                ((LayoutControlItem)item).AppearanceItemCaption.Options.UseForeColor = true;
                            }
                            else
                            {
                                ((LayoutControlItem)item).Text = itemText + ":";
                                ((LayoutControlItem)item).AppearanceItemCaption.Options.UseForeColor = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrBox(ex);
            }
        }
示例#3
0
        /// <summary>
        /// GridColumn 배열로 그리드의 컬럼을 추가한다.
        /// </summary>
        /// <param name="columns">GridColumn 배열</param>
        public void AddGridColumns(params GridColumn[] columns)
        {
            MainView.BeginUpdate();

            MainView.Columns.Clear();

            foreach (GridColumn col in columns)
            {
                if (string.IsNullOrEmpty(col.Caption))
                {
                    col.Caption = DomainUtils.GetFieldName(col.FieldName);
                }
                col.OptionsColumn.AllowMerge                = DefaultBoolean.False;
                col.OptionsFilter.FilterPopupMode           = FilterPopupMode.CheckedList;
                col.CustomizationCaption                    = col.Caption;
                col.AppearanceHeader.Options.UseTextOptions = true;
                col.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            }

            MainView.Columns.AddRange(columns);

            MainView.EndUpdate();
        }
示例#4
0
 protected virtual void SetFieldName(LayoutControlItem item, string fieldName, HorzAlignment horzAlign, VertAlignment vertAlign)
 {
     item.Text = DomainUtils.GetFieldName(fieldName) + ":";
 }
示例#5
0
        /// <summary>
        /// 그리드의 밴드에 컬럼을 추가한다.
        /// </summary>
        /// <param name="column">XGridColumn</param>
        public void AddBandColumn(XGridColumn column)
        {
            //Caption
            if (string.IsNullOrEmpty(column.Caption))
            {
                if (!string.IsNullOrEmpty(column.CaptionCode))
                {
                    column.Caption = DomainUtils.GetFieldName(column.CaptionCode);
                }
                else
                {
                    column.Caption = DomainUtils.GetFieldName(column.FieldName);
                }
            }

            var bandedColumn = new BandedGridColumn()
            {
                Caption     = column.Caption,
                FieldName   = column.FieldName,
                UnboundType = column.ColumnType
            };

            bandedColumn.OptionsColumn.AllowMerge                = DefaultBoolean.False;
            bandedColumn.OptionsFilter.FilterPopupMode           = FilterPopupMode.CheckedList;
            bandedColumn.CustomizationCaption                    = bandedColumn.Caption;
            bandedColumn.AppearanceHeader.Options.UseTextOptions = true;
            bandedColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            bandedColumn.AppearanceCell.Options.UseTextOptions   = true;
            switch (column.FieldName)
            {
            case "ROW_NO":
            case "INS_TIME":
            case "INS_USER":
            case "INS_USER_NAME":
            case "UPD_TIME":
            case "UPD_USER":
            case "UPD_USER_NAME":
                bandedColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
                break;

            default:
                if (column.FieldName.EndsWith("_DATE"))
                {
                    bandedColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
                }
                else
                {
                    bandedColumn.AppearanceCell.TextOptions.HAlignment = column.HorzAlignment;
                }
                break;
            }


            bandedColumn.DisplayFormat.FormatType   =
                bandedColumn.GroupFormat.FormatType = column.FormatType;

            if (!string.IsNullOrEmpty(column.FormatString))
            {
                bandedColumn.DisplayFormat.FormatString = column.FormatString;
                bandedColumn.GroupFormat.FormatString   = column.FormatString;
            }

            if (column.RepositoryItem != null)
            {
                bandedColumn.ColumnEdit = column.RepositoryItem;
            }

            if ((column.IsSummary) &&
                (MainView.GetType() == typeof(GridView) || MainView.GetType() == typeof(BandedGridView) || MainView.GetType() == typeof(AdvBandedGridView)))
            {
                bandedColumn.SummaryItem.SummaryType = column.SummaryItemType;
                bandedColumn.SummaryItem.FieldName   = column.FieldName;

                if (!string.IsNullOrEmpty(column.FormatString))
                {
                    bandedColumn.SummaryItem.DisplayFormat = string.Format("{{0:{0}}}", column.FormatString);
                }

                if (column.IsSummaryGroup)
                {
                    var item = new GridGroupSummaryItem()
                    {
                        FieldName = column.FieldName,
                        ShowInGroupColumnFooter     = bandedColumn,
                        ShowInGroupColumnFooterName = column.FieldName,
                        SummaryType = column.SummaryItemType
                    };

                    if (!string.IsNullOrEmpty(column.FormatString))
                    {
                        item.DisplayFormat = string.Format("{{0:{0}}}", column.FormatString);
                    }
                    GroupSummaryAdd(item);

                    bandedColumn.OptionsColumn.AllowGroup = DefaultBoolean.True;
                }
            }

            if (column.ReadOnly || MainView.OptionsBehavior.Editable == false)
            {
                bandedColumn.OptionsColumn.ReadOnly   = true;
                bandedColumn.OptionsColumn.AllowEdit  = false;
                bandedColumn.OptionsColumn.AllowFocus = false;
            }
            else
            {
                bandedColumn.OptionsColumn.ReadOnly   = false;
                bandedColumn.OptionsColumn.AllowEdit  = true;
                bandedColumn.OptionsColumn.AllowFocus = true;
            }

            if (column.Width > 0)
            {
                bandedColumn.Width    = column.Width;
                bandedColumn.MinWidth = column.Width;
            }
            else
            {
                switch (column.FieldName)
                {
                case "ROW_NO":
                    bandedColumn.Width    = 50;
                    bandedColumn.MinWidth = 50;
                    break;

                case "INS_TIME":
                case "UPD_TIME":
                    bandedColumn.Width    = 150;
                    bandedColumn.MinWidth = 150;
                    break;

                case "INS_USER":
                case "UPD_USER":
                    bandedColumn.Width    = 100;
                    bandedColumn.MinWidth = 100;
                    break;

                case "INS_USER_NAME":
                case "UPD_USER_NAME":
                    bandedColumn.Width    = 100;
                    bandedColumn.MinWidth = 100;
                    break;

                default:
                    if (column.FieldName.EndsWith("_DATE"))
                    {
                        bandedColumn.Width    = 100;
                        bandedColumn.MinWidth = 100;
                    }
                    else
                    {
                        bandedColumn.BestFit();
                    }
                    break;
                }
            }

            bandedColumn.Visible = column.Visible;

            if (column.Visible)
            {
                bandedColumn.VisibleIndex = MainView.Columns.Count;
            }
            MainView.Columns.Add(bandedColumn);
        }