📌  相关文章
📜  windows窗体从infragistic Ultra网格中的列选择器选项中隐藏列-NAYCode.com-任何(1)

📅  最后修改于: 2023-12-03 15:21:11.304000             🧑  作者: Mango

在Infragistic Ultra网格中隐藏列的Windows窗体

在使用Infragistic Ultra网格时,有时会需要隐藏某些列。通过Infragistic Ultra网格提供的列选择器选项,程序员可以轻松地隐藏列。以下是如何使用列选择器选项在Infragistic Ultra网格中隐藏列的步骤:

步骤1:设置列选择器选项

在Infragistic Ultra网格的属性中,找到 “列选择器选项” 并将其设置为 “启用”。

this.ultraGrid1.DisplayLayout.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.ColSort;
this.ultraGrid1.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
this.ultraGrid1.DisplayLayout.Override.AllowMultiCellOperations = Infragistics.Win.UltraWinGrid.AllowMultiCellOperation.All;
this.ultraGrid1.DisplayLayout.Override.AllowMultiRowSelection = Infragistics.Win.DefaultableBoolean.True;
this.ultraGrid1.DisplayLayout.Override.AllowRowSummaries = Infragistics.Win.UltraWinGrid.AllowRowSummaries.True;
this.ultraGrid1.DisplayLayout.Override.BorderStyleHeader = Infragistics.Win.UIElementBorderStyle.RaisedSoft;
this.ultraGrid1.DisplayLayout.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Solid;
this.ultraGrid1.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
this.ultraGrid1.DisplayLayout.Override.ExpansionIndicator = Infragistics.Win.UltraWinGrid.ShowExpansionIndicator.CheckOnDisplay;
this.ultraGrid1.DisplayLayout.Override.HeaderAppearance = headerAppearance1;
this.ultraGrid1.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.XPThemed;
this.ultraGrid1.DisplayLayout.Override.MinRowHeight = 0;
this.ultraGrid1.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
this.ultraGrid1.DisplayLayout.Override.RowSizing = Infragistics.Win.UltraWinGrid.RowSizing.AutoFree;
this.ultraGrid1.DisplayLayout.Override.SelectTypeCell = Infragistics.Win.UltraWinGrid.SelectType.None;
this.ultraGrid1.DisplayLayout.Override.SelectTypeCol = Infragistics.Win.UltraWinGrid.SelectType.None;
this.ultraGrid1.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Single;
this.ultraGrid1.DisplayLayout.Override.SummaryDisplayArea = Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.BottomFixed;
this.ultraGrid1.DisplayLayout.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
this.ultraGrid1.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
this.ultraGrid1.DisplayLayout.UseFixedHeaders = true;
this.ultraGrid1.DisplayLayout.Override.RowSelectorWidth = 22;
this.ultraGrid1.DisplayLayout.Override.RowSelectorAppearance = rowSelectorAppearance1;
this.ultraGrid1.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
this.ultraGrid1.DisplayLayout.Override.HeaderCheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.WhenUsingCheckEditor;
this.ultraGrid1.DisplayLayout.Override.HeaderCheckBoxAlignment = Infragistics.Win.HAlign.Left;
this.ultraGrid1.DisplayLayout.Override.HeaderCheckBoxVisibility = HeaderCheckBoxVisibility.WhenUsingDropDown;
this.ultraGrid1.DisplayLayout.Override.SelectTypeCol = Infragistics.Win.UltraWinGrid.SelectType.None;
this.ultraGrid1.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Single;
this.ultraGrid1.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
this.ultraGrid1.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False;
this.ultraGrid1.DisplayLayout.Override.CellAppearance.BackColor = Color.White;
this.ultraGrid1.DisplayLayout.Override.CellAppearance.BorderColor = Color.FromArgb(110, 117, 125);
this.ultraGrid1.DisplayLayout.Override.CellAppearance.FontData.Name = "Segoe UI";
this.ultraGrid1.DisplayLayout.Override.CellAppearance.FontData.SizeInPoints = 9f;
this.ultraGrid1.DisplayLayout.Override.CellAppearance.TextHAlignAsString = "Left";
this.ultraGrid1.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.Edit;
this.ultraGrid1.DisplayLayout.Override.DefaultColWidth = 105;
this.ultraGrid1.DisplayLayout.Override.DefaultRowHeight = 20;
this.ultraGrid1.DisplayLayout.Override.ExpansionIndicator = ShowExpansionIndicator.CheckOnDisplay;
this.ultraGrid1.DisplayLayout.Override.FixedHeaderIndicator = FixedHeaderIndicator.None;
this.ultraGrid1.DisplayLayout.Override.HeaderCheckBoxVisibility = HeaderCheckBoxVisibility.None;
this.ultraGrid1.DisplayLayout.Override.HeaderStyle = HeaderStyle.Standard;
this.ultraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True;
this.ultraGrid1.DisplayLayout.Override.RowSelectorWidth = 22;
this.ultraGrid1.DisplayLayout.Override.SelectTypeRow = SelectType.Single;
this.ultraGrid1.DisplayLayout.Override.SummaryDisplayArea = SummaryDisplayAreas.None;
this.ultraGrid1.DisplayLayout.ScrollBounds = ScrollBounds.ScrollToFill;
this.ultraGrid1.DisplayLayout.ScrollStyle = ScrollStyle.Immediate;
this.ultraGrid1.DisplayLayout.TabNavigation = TabNavigation.NextCell;
this.ultraGrid1.DisplayLayout.ViewStyle = ViewStyle.SingleBand;
this.ultraGrid1.Dock = DockStyle.Fill;
this.ultraGrid1.Location = new Point(0, 0);
this.ultraGrid1.RightToLeft = RightToLeft.No;
this.ultraGrid1.Size = new Size(784, 362);
this.ultraGrid1.TabIndex = 0;
this.ultraGrid1.Text = "ultraGrid1";
this.ultraGrid1.DisplayLayout.Override.SelectTypeCol = SelectType.None;
this.ultraGrid1.DisplayLayout.Override.SelectTypeRow = SelectType.Single;
this.ultraGrid1.DisplayLayout.ColumnChooserEnabled = DefaultableBoolean.True;
this.ultraGrid1.DataSource = this.dataSet1;
this.ultraGrid1.DisplayLayout.ColumnChooserDisplayStyle = Infragistics.Win.UltraWinGrid.ColumnChooserDisplayStyle.DisplayTextAndCheckboxes;
步骤2:隐藏列
  1. 右击Infragistic Ultra网格的列标题。
  2. 在弹出的菜单中,选择“列选择器”。
  3. 在弹出的列选择器选项对话框中,取消选择需要隐藏的列。
  4. 单击“确定”按钮。
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
    e.Layout.Override.ColumnChooserEnabled = Infragistics.Win.DefaultableBoolean.True;
    e.Layout.Override.ColumnChooserDisplayStyle = Infragistics.Win.UltraWinGrid.ColumnChooserDisplayStyle.DisplayTextAndChecks;
}
步骤3:更新网格

在重新加载网格之前,必须先调用Infragistic Ultra网格的更新方法。以下是一个示例:

private void HideColumn()
{
    // 隐藏列
    this.ultraGrid1.DisplayLayout.Bands[0].Columns["ColumnName"].Hidden = true;
    // 更新网格
    this.ultraGrid1.Update();
}
结论

如此简单,程序员就可以在Infragistic Ultra网格中隐藏不需要的列了。只需几个简单的步骤,即可完成这项任务。