当前位置: 首页>>代码示例>>C#>>正文


C# GridView.BestFitColumns方法代码示例

本文整理汇总了C#中GridView.BestFitColumns方法的典型用法代码示例。如果您正苦于以下问题:C# GridView.BestFitColumns方法的具体用法?C# GridView.BestFitColumns怎么用?C# GridView.BestFitColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GridView的用法示例。


在下文中一共展示了GridView.BestFitColumns方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BestFitMasterColumns

 /// <summary>Chỉnh độ rộng của cột theo dạng đẹp nhất có thể
 /// </summary>
 public static void BestFitMasterColumns(GridView gridView)
 {
     gridView.GridControl.Load += delegate(object sender, EventArgs e)
     {
         gridView.BestFitColumns();
     };
 }
开发者ID:khanhdtn,项目名称:my-office-manager,代码行数:9,代码来源:PLGUIUtil.cs

示例2: BaseGridViewControlSetting

 public static GridView BaseGridViewControlSetting(GridView gridView, bool autoWidth)
 {
     gridView.OptionsView.ColumnAutoWidth = autoWidth;
     gridView.OptionsBehavior.Editable = false;
     gridView.OptionsSelection.EnableAppearanceFocusedCell = false;
     gridView.OptionsView.ShowIndicator = false;
     gridView.OptionsView.ShowGroupPanel = false;
     gridView.FocusRectStyle = DrawFocusRectStyle.None;
     gridView.BestFitColumns();
     return gridView;
 }
开发者ID:gofixiao,项目名称:HYPDM_Pro,代码行数:11,代码来源:BaseGridViewControl.cs

示例3: CreateDM_TAI_LIEU

        public static GridColumn[] CreateDM_TAI_LIEU(GridControl gridControl, GridView gridView)
        {
            XtraGridSupportExt.TextLeftColumn(
                XtraGridSupportExt.CreateGridColumn(gridView, "ID", -1, -1), "ID");
            XtraGridSupportExt.TextLeftColumn(
                XtraGridSupportExt.CreateGridColumn(gridView, "Tên tài liệu", 0, 150), "NAME");

            GridColumn ColLoai = XtraGridSupportExt.CreateGridColumn(gridView, "Loại tài liệu", 1, 150);
            ColLoai.FieldName = "LOAI_TAI_LIEU_ID";
            XtraGridSupportExt.IDGridColumn(ColLoai, "ID", "NAME", "DM_LOAI_TAI_LIEU", "LOAI_TAI_LIEU_ID");
            ColLoai.OptionsColumn.AllowEdit = true;
            ColLoai.OptionsColumn.AllowFocus = false;
            ColLoai.OptionsColumn.ReadOnly = true;
            gridView.GroupCount = 1;
            gridView.SortInfo.AddRange(new DevExpress.XtraGrid.Columns.GridColumnSortInfo[] {
                new DevExpress.XtraGrid.Columns.GridColumnSortInfo(ColLoai, DevExpress.Data.ColumnSortOrder.Ascending)}
            );
            HelpGridColumn.CotMemoEdit(gridView,
                XtraGridSupportExt.CreateGridColumn(gridView, "Mô tả", 3, 150), "MO_TA");
            XtraGridSupportExt.TextLeftColumn(
                XtraGridSupportExt.CreateGridColumn(gridView, "Phiên bản", 4, 150), "PHIEN_BAN");
            XtraGridSupportExt.ComboboxGridColumn(
               XtraGridSupportExt.CreateGridColumn(gridView, "Người gửi", 5, 150), DADocument.getDM_NHAN_VIEN(), "ID", "NAME", "NGUOI_GUI");
            XtraGridSupportExt.DateTimeGridColumn(
               XtraGridSupportExt.CreateGridColumn(gridView, "Ngày gửi", 6, 150), "NGAY_GUI");
            XtraGridSupportExt.ComboboxGridColumn(
               XtraGridSupportExt.CreateGridColumn(gridView, "Người cập nhật", 7, 150), DADocument.getDM_NHAN_VIEN(), "ID", "NAME", "NGUOI_CAP_NHAT");
            XtraGridSupportExt.DateTimeGridColumn(
               XtraGridSupportExt.CreateGridColumn(gridView, "Ngày cập nhật", 8, 150), "NGAY_CAP_NHAT");
            gridView.GroupPanelText = "Danh sách tài liệu";
            gridView.BestFitColumns();
            gridView.HorzScrollVisibility = DevExpress.XtraGrid.Views.Base.ScrollVisibility.Always;

            gridView.Columns["NGUOI_GUI"].OptionsColumn.AllowEdit = false;
            gridView.Columns["NGAY_GUI"].OptionsColumn.AllowEdit = false;
            gridView.Columns["NGUOI_CAP_NHAT"].OptionsColumn.AllowEdit = false;
            gridView.Columns["NGAY_CAP_NHAT"].OptionsColumn.AllowEdit = false;
            gridView.OptionsView.ColumnAutoWidth = false;
            return null;
        }
开发者ID:khanhdtn,项目名称:my-office-manager,代码行数:40,代码来源:DMTaiLieu.cs

示例4: PersonForm

        public PersonForm(PersonRowData person)
        {
            InitializeComponent();

            this.person = person;

            Text = person.Person.FullName + " - " + person.Person.Id;
            personInfo.EditValue = person.Person.ToFullString();
            personInfo.SuperTip = Utilities.CreateSuperTip(body: person.Person.ToFullString());

            infoSource.Caption += person.Person.Source;
            infoStripeId.Caption += person.StripeId;
            infoYKID.Caption += person.Person.YKID;

            foreach (DataTable table in person.DataSet.Tables) {
                var grid = new GridControl() {
                    Dock = DockStyle.Fill,
                    DataSource = table,
                };

                tabs.TabPages.Add(new XtraTabPage {
                    Text = table.TableName,
                    Controls = { grid }
                });

                var view = new GridView();
                grid.MainView = view;
                view.PopulateColumns();

                view.OptionsBehavior.Editable = false;

                foreach (GridColumn column in view.Columns) {
                    if (hiddenFields.Contains(column.FieldName)
                     || column.FieldName == pluralizer.Singularize(Path.GetExtension(table.TableName).TrimStart('.')) + "Id")
                        column.Visible = false;
                }

                view.BestFitColumns();
            }
        }
开发者ID:ShomreiTorah,项目名称:Utilities,代码行数:40,代码来源:PersonForm.cs

示例5: SetBestFitForColumns

        private void SetBestFitForColumns(GridView gridView) {
            if (gridView != null) {
                //Calculate the estimated best width
                int estimatedBestWidth = 0;

                //To avoid a full grid scan, only use the 20 first rows to set the best fit
                gridView.BestFitMaxRowCount = 20;

                foreach (GridColumn column in gridView.Columns) {
                    estimatedBestWidth += column.GetBestWidth();
                }

                //If the calculated best width is greater than the grid width
                if (estimatedBestWidth > gridView.GridControl.Width || true) {
                    //Disable the column autowidth (which is true by default) to allow the scrollbar to appear
                    gridView.OptionsView.ColumnAutoWidth = false;

                    //And force the columns to resize to its best width
                    gridView.BestFitColumns();
                }
            }
        }
开发者ID:dioptre,项目名称:nkd,代码行数:22,代码来源:GridControlViewController.cs

示例6: GridSetViewOption


//.........这里部分代码省略.........
                view.ViewStylesInfo.Row.Font = font;
                view.ViewStylesInfo.FocusedRow.Font = font;
                view.ViewStylesInfo.FocusedCell.Font = font;
            }

            StyleOptions style;
            if (XtraGridTools.GetStyleOptions(definition.zAttribValue("StyleFocusedRow"), out style))
                view.ViewStylesInfo.FocusedRow.Options = style;
            if (XtraGridTools.GetStyleOptions(definition.zAttribValue("StyleSelectedRow"), out style))
                view.ViewStylesInfo.SelectedRow.Options = style;
            if (XtraGridTools.GetStyleOptions(definition.zAttribValue("StyleHideSelectionRow"), out style))
                view.ViewStylesInfo.HideSelectionRow.Options = style;

            //OptionsDetail
            view.OptionsDetail.EnableMasterViewMode = option.MasterViewMode;
            view.OptionsDetail.AllowZoomDetail = option.AllowZoomDetail;
            view.OptionsDetail.SmartDetailExpand = option.SmartDetailExpand;
            view.OptionsDetail.AllowExpandEmptyDetails = option.AllowExpandEmptyDetails;
            view.OptionsDetail.AutoZoomDetail = option.AutoZoomDetail;
            view.OptionsDetail.EnableDetailToolTip = option.EnableDetailToolTip;
            view.OptionsDetail.ShowDetailTabs = option.ShowDetailTabs;
            view.OptionsDetail.SmartDetailHeight = option.SmartDetailHeight;

            view.OptionsBehavior.Editable = false;

            view.OptionsView.ShowNewItemRow = false;
            if (!option.ReadOnly)
            {
                if (!option.NoUpdate) view.OptionsBehavior.Editable = true;
                if (!option.NoInsert && !option.NoInsertButton) view.OptionsView.ShowNewItemRow = true;
            }

            if (!option.NoMultiSelect) view.OptionsSelection.MultiSelect = true;

            //if (gbTrace) cTrace.StartNestedLevel("GridSetViewOption_2");
            IEnumerable<XElement> colDefinitions = null;
            if (definition != null)
            {
                colDefinitions = definition.Elements("col");
                foreach (XElement colDefinition in colDefinitions)
                {
                    string sColName = colDefinition.zAttribValue("Name");
                    GridColumn colGrid = view.Columns[sColName];
                    if (colGrid == null)
                    {
                        colGrid = view.Columns.Add();
                        colGrid.Name = sColName;
                        colGrid.Caption = sColName;
                        colGrid.FieldName = sColName;
                        colGrid.VisibleIndex = view.VisibleColumns.Count;
                    }
                    if (colGrid != null)
                    {
                        string sOption = colDefinition.zAttribValue("Option", "");
                        string sCaption = colDefinition.zAttribValue("Caption");
                        if (sCaption != null) colGrid.Caption = sCaption;
                        XtraGridTools.SetGridColumnOption(colGrid, sOption);
                        XtraGridTools.SetGridColumnStyle(colGrid, colDefinition.zAttribValue("Style"));
                        XtraGridTools.SetGridColumnFormatDate(colGrid, colDefinition.zAttribValue("FormatDate"));
                        XtraGridTools.SetGridColumnFormatNum(colGrid, colDefinition.zAttribValue("FormatNum"));
                        //////////SetGridColumnEdit(view, con, dataList, colGrid, col.zAttribValue("Edit"), col);
                        IDbConnection con = GetConnection();
                        DataList dataList = GetDataList();
                        SortedList<string, RepositoryItem> editRepositoryList = GetEditRepositoryList();
                        XtraGridTools gridTools = new XtraGridTools(con, dataList, editRepositoryList);
                        gridTools.SetColumnEdit(colGrid, colDefinition);
                    }
                }
            }
            XtraGridTools.SetGridColumnsDefaultEdit(view);
            //if (gbTrace) cTrace.StopNestedLevel("GridSetViewOption_2");

            //((System.ComponentModel.ISupportInitialize)(view)).EndInit();

            //if (gbTrace) cTrace.StartNestedLevel("BestFitColumns");
            if (!option.NoBestFitColumns)
            {
                view.BestFitMaxRowCount = 50;
                view.BestFitColumns();
            }
            //if (gbTrace) cTrace.StopNestedLevel("BestFitColumns");

            if (colDefinitions != null)
            {
                foreach (XElement col in colDefinitions)
                {
                    GridColumn colGrid = view.Columns[col.zAttribValue("Name")];
                    //XtraGridTools.SetGridColumnWidth(colGrid, col.zAttribValueInt("Width", -1));
                    XtraGridTools.SetGridColumnWidth(colGrid, col.zAttribValue("Width").zTryParseAs<int>(-1));
                }
            }

            string sSort = definition.zAttribValue("Sort");
            XtraGridTools.SetGridSort(view, sSort);

            //XtraGridTools.LoadParameters(view, definition);
            //LoadParameters(view);

            //if (gbTrace) cTrace.StopNestedLevel("GridSetViewOption");
        }
开发者ID:labeuze,项目名称:source,代码行数:101,代码来源:XtraGrid.cs

示例7: DisplayTheoTuyBienCot

 /// <summary>
 /// Hiển thị các cột đã được chọn
 /// </summary>
 /// <param name="gridView"></param>
 /// <param name="cotHienThi"></param>
 public static void DisplayTheoTuyBienCot(GridView gridView, RepositoryItemCheckedComboBoxEdit cotHienThi)
 {
     //gridView.ClearGrouping();
     List<string> listCotHienThi = new List<string>(cotHienThi.GetCheckedItems().ToString().Split(','));
     int i = 0;
     foreach (GridColumn column in gridView.Columns) {
         if (listCotHienThi.Exists(delegate(string visibleName)
         {
             return string.Compare(visibleName.Trim(), column.Name) == 0;
         })){
             column.Visible = true;
             column.VisibleIndex = i++;
         }
         else column.Visible = false;
     }
     gridView.BestFitColumns();
 }
开发者ID:khanhdtn,项目名称:did-vlib-2011,代码行数:22,代码来源:AppCtrl.cs

示例8: CreateGrid

        private void CreateGrid()
        {
            Control ctrl = Control.FromHandle(m_WHandle);
            if (ctrl == null)
            {
                throw new Exception("请选择目标GRID");
            }
            ctrl.Refresh();
            try
            {
                m_ctrlGrid = null;
#if(Devxpress)
                if (ctrl is GridControl)
                {
                    GridControl efGridControlSource = ctrl as GridControl;
                    GridView gridViewSource = efGridControlSource.MainView as GridView;

                    m_ctrlGrid = new GridControl();
                    efGroupBox2.Controls.Clear();
                    efGroupBox2.Controls.Add(m_ctrlGrid);
                    m_ctrlGrid.Parent = efGroupBox2;
                    m_ctrlGrid.Visible = true;
                    m_ctrlGrid.Dock = DockStyle.Fill;

                    GridControl efGridControlDest = m_ctrlGrid as GridControl;

                    GridView gridViewDesc = new GridView(efGridControlDest);
                    efGridControlDest.MainView = gridViewDesc;
                    gridViewDesc.OptionsView.ShowGroupPanel = false;

                    gridViewDesc.OptionsView.AllowHtmlDrawHeaders
                        = gridViewSource.OptionsView.AllowHtmlDrawHeaders;

                    gridViewDesc.Appearance.HeaderPanel.TextOptions.Trimming
                        = gridViewSource.Appearance.HeaderPanel.TextOptions.Trimming;

                    gridViewDesc.Appearance.HeaderPanel.TextOptions.WordWrap
                        = gridViewSource.Appearance.HeaderPanel.TextOptions.WordWrap;

                    gridViewDesc.Appearance.HeaderPanel.Options.UseTextOptions
                        = gridViewSource.Appearance.HeaderPanel.Options.UseTextOptions;

                    System.Data.DataSet dsDataSource = null;
                    // 复制数据源
                    if (efGridControlSource.DataSource is BindingSource)
                    {
                        BindingSource bindingSource = efGridControlSource.DataSource as BindingSource;
                        if (bindingSource.DataSource is System.Data.DataSet)
                        {
                            dsDataSource = (bindingSource.DataSource as System.Data.DataSet).Clone();
                            efGridControlDest.DataMember = bindingSource.DataMember;
                        }
                        else if (bindingSource.DataSource is DataTable)
                        {
                            dsDataSource = new System.Data.DataSet();
                            DataTable dt = (bindingSource.DataSource as DataTable).Clone();
                            dsDataSource.Tables.Add(dt);
                            efGridControlDest.DataMember = dt.TableName;
                        }
                        else
                        {
                        }
                    }
                    else if (efGridControlSource.DataSource is System.Data.DataSet)
                    {
                        dsDataSource = (efGridControlSource.DataSource as System.Data.DataSet).Copy();
                        efGridControlDest.DataMember = efGridControlSource.DataMember;
                    }
                    else if (efGridControlSource.DataSource is System.Data.DataTable)
                    {
                        dsDataSource = new System.Data.DataSet();
                        DataTable dt = (efGridControlSource.DataSource as System.Data.DataTable).Copy();
                        dsDataSource.Tables.Add(dt);
                        efGridControlDest.DataMember = dt.TableName;
                    }


                    efGridControlDest.BeginUpdate();
                    gridViewDesc.BeginUpdate();

                    GridColumn gridColumnDesc = null;

                    foreach (GridColumn gridcol in gridViewSource.VisibleColumns)
                    {
                        gridColumnDesc = new GridColumn();
                        gridColumnDesc.Name = gridcol.Name;
                        gridColumnDesc.FieldName = gridcol.FieldName;
                        gridColumnDesc.Caption = gridcol.Caption;
                        gridViewDesc.Columns.Add(gridColumnDesc);
                        gridColumnDesc.Visible = true;
                        gridColumnDesc.VisibleIndex = gridViewDesc.VisibleColumns.Count;
                        gridColumnDesc.OptionsColumn.ReadOnly = true;
                    }
                    efGridControlDest.DataSource = dsDataSource;
                    gridViewDesc.OptionsView.ColumnAutoWidth = false;
                    gridViewDesc.IndicatorWidth = 30;
                    gridViewDesc.BestFitColumns();
                    gridViewDesc.OptionsCustomization.AllowColumnMoving = false;
                    gridViewDesc.EndUpdate();
                    efGridControlDest.EndUpdate();
//.........这里部分代码省略.........
开发者ID:sunpander,项目名称:VSDT,代码行数:101,代码来源:FormEPEDEXCEL.cs

示例9: AddTuyBienCot

        private static BarEditItem AddTuyBienCot(BarManager barManager, LinksInfo linksInfo, string caption,
            GridView gridView, GridColumn[] excludeColumns,
            params string[] defaultColumns)
        {
            var repositoryItemCheckedCotHienThi = new RepositoryItemCheckedComboBoxEdit
                                                      {
                                                          AutoHeight = false,
                                                          BestFitWidth = 180,
                                                          Name = "repositoryItemCheckedCotHienThi"
                                                      };
            //
            // repositoryItemCheckedCotHienThi
            //

            //
            var barEditItemCotHienThi = new BarEditItem
                                            {
                                                Caption = string.IsNullOrEmpty(caption) ? "&Cột hiển thị" : caption,
                                                Edit = repositoryItemCheckedCotHienThi,
                                                Name = "barEditItem1",
                                                PaintStyle = BarItemPaintStyle.CaptionGlyph,
                                                Width = 200
                                            };
            //
            // barEditItemCotHienThi
            //
            //
            barManager.Items.Add(barEditItemCotHienThi);
            barManager.RepositoryItems.AddRange(new RepositoryItem[]
                                                    {
                                                        repositoryItemCheckedCotHienThi
                                                    });
            //
            linksInfo.Add(new LinkPersistInfo(barEditItemCotHienThi, true));
            //Gán. các cột vào CheckedComboBox
            var columns = gridView.Columns.Cast<GridColumn>().OrderBy(cl => cl.Caption);
            if (excludeColumns == null || excludeColumns.Length == 0)
            {
                foreach (GridColumn column in columns)
                {
                    //repositoryItemCheckedCotHienThi.Items.Add(column.Name, column.Caption);
                    repositoryItemCheckedCotHienThi.Items.Add(column,
                                                              !string.IsNullOrEmpty(column.CustomizationCaption)
                                                                  ? column.CustomizationCaption
                                                                  : column.Caption);
                }
            }
            else
            {
                var listExcludeCol = new List<GridColumn>(excludeColumns);
                foreach (GridColumn column in columns)
                {
                    if (listExcludeCol.Any(c => c.Name == column.Name))
                    {
                        column.Visible = false;
                        column.OptionsColumn.AllowShowHide = false;
                        continue;
                    }
                    //repositoryItemCheckedCotHienThi.Items.Add(column.Name, column.Caption);
                    repositoryItemCheckedCotHienThi.Items.Add(column,
                                                              !string.IsNullOrEmpty(column.CustomizationCaption)
                                                                  ? column.CustomizationCaption
                                                                  : column.Caption);

                }
            }

            //-------------------------------
            //
            repositoryItemCheckedCotHienThi.CloseUp += delegate(object sender, CloseUpEventArgs e)
                                                           {
                                                               var value = new StringBuilder();
                                                               foreach (
                                                                   CheckedListBoxItem item in
                                                                       (sender as CheckedComboBoxEdit).Properties.Items)
                                                               {
                                                                   if (item.CheckState == CheckState.Checked)
                                                                   {
                                                                       value.Append(" " + item.Description +
                                                                                    (sender as CheckedComboBoxEdit).
                                                                                        Properties.SeparatorChar.
                                                                                        ToString());
                                                                       ((GridColumn)item.Value).Visible = true;
                                                                   }
                                                                   else
                                                                   {
                                                                       ((GridColumn)item.Value).Visible = false;
                                                                   }
                                                               }
                                                               e.Value = value.Length > 0
                                                                             ? value.ToString().Remove(value.Length - 1)
                                                                             : string.Empty;
                                                               gridView.BestFitColumns();
                                                           };
            //
            //Kiểm tra đã tồn tại layout cho gridView
            var str = new StringBuilder(FrameworkParams.currentUser.username);
            str.Append(gridView.GridControl.FindForm().Name + gridView.GridControl.Name +
                       gridView.Name);
            var listFile = new List<FileInfo>(new DirectoryInfo(FrameworkParams.LAYOUT_FOLDER).GetFiles());
//.........这里部分代码省略.........
开发者ID:khanhdtn,项目名称:did-vlib-2011,代码行数:101,代码来源:AppCtrl.cs

示例10: PLBestFit

        /// <summary>
        /// Tự động chỉnh lại độ rộng cho phù hợp
        /// </summary>        
        public static bool PLBestFit(GridView grid)
        {
            try
            {
                grid.OptionsView.ColumnAutoWidth = true;
                int totalWidth = 0;
                for (int i = 0; i < grid.VisibleColumns.Count; i++)
                {
                    totalWidth += grid.VisibleColumns[i].VisibleWidth;
                }
                grid.OptionsView.ColumnAutoWidth = false;

                int totalWidthBest = 0;
                grid.BestFitColumns();
                for (int i = 0; i < grid.VisibleColumns.Count; i++)
                {
                    totalWidthBest += grid.VisibleColumns[i].VisibleWidth;
                }

                if (totalWidth < totalWidthBest)
                {
                    grid.OptionsView.ColumnAutoWidth = false;
                }
                else
                    grid.OptionsView.ColumnAutoWidth = true;

                return true;
            }
            catch (Exception ex)
            {
                PLException.AddException(ex);
            }
            return false;
        }
开发者ID:khanhdtn,项目名称:my-fw-win,代码行数:37,代码来源:HelpGrid.cs


注:本文中的GridView.BestFitColumns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。