Version

ColumnsCollection Class

Returns a reference to a collection of Column objects. This property is read-only at run-time. This property is not available at design-time.
Syntax
'Declaration
 
Public Class ColumnsCollection 
   Inherits Infragistics.Shared.KeyedSubObjectsCollectionBase
public class ColumnsCollection : Infragistics.Shared.KeyedSubObjectsCollectionBase 
Remarks

This property returns a reference to a collection of UltraGridColumn objects that can be used to retrieve references to the Column objects that, for the Band and Group objects, belong to a band or a group, respectively, or for the Selected object, that are currently selected. You can use this reference to access any of the returned collection's properties or methods, as well as the properties or methods of the objects within the collection.

For the Selected object, as columns are selected and deselected, their corresponding Column objects are added to and removed from the SelectedCols collection returned by this property. When a column is selected or deselected, the BeforeSelectChange event is generated.

The Count property of the returned collection can be used to determine the number of columns that either belong to a band or a group or are currently selected.

Example
InitializeLayout event is a good place to initialize the grid. Following code sets some of the commonly used properties on the grid.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ultraGrid1.InitializeLayout

      ' Enable row filtering on the first band only and set the RowFilterMode to
      ' AllRowInBand which dictates that the UltraGrid use UltraGridBand.ColumnFilters 
      ' rather than RowsCollection.ColumnFilters.
      e.Layout.Bands(0).Override.AllowRowFiltering = DefaultableBoolean.True
      e.Layout.Bands(0).Override.RowFilterMode = RowFilterMode.AllRowsInBand

      ' Set the AllowRowSummaries to either True or BasedOnDataType to allow
      ' the user to be able to add, remove or modify summaries. This is not 
      ' necessary to create summaries programmatically and only effects the 
      ' users ability to create, remove or modify summaries.
      e.Layout.Bands(2).Override.AllowRowSummaries = AllowRowSummaries.BasedOnDataType

      ' You can also prevent the user from adding, removing or modifying a
      ' summary on a column basis. This prevents the user from summarizing OrderID 
      ' and ProductID columns.
      e.Layout.Bands(2).Columns("OrderID").AllowRowSummaries = AllowRowSummaries.False
      e.Layout.Bands(2).Columns("ProductID").AllowRowSummaries = AllowRowSummaries.False

      ' Set the HeaderClickAction to SortMulti to allow the user to sort 
      ' columns by clickin on the column headers.
      e.Layout.Override.HeaderClickAction = HeaderClickAction.SortMulti

      ' Set various appearances using Override. Override off the DisplayLayout sets 
      ' grid-wide appearances while Override off individual bands sets the appearances
      ' for that particular band.
      e.Layout.Override.CellAppearance.BackColor = Color.LightCyan

      ' You can override these for a specific band, in this case band 2.
      e.Layout.Bands(2).Override.CellAppearance.BackColor = Color.Beige

      ' You can also override appearance for individual columns.
      e.Layout.Bands(0).Columns("CustomerID").CellAppearance.ForeColor = Color.Gray

      ' Set the CustomerID column's VisiblePosition to 0 so it's the first column
      ' on the display.
      e.Layout.Bands(0).Columns("CustomerID").Header.VisiblePosition = 0

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{	
		
	// Enable row filtering on the first band only and set the RowFilterMode to
	// AllRowInBand which dictates that the UltraGrid use UltraGridBand.ColumnFilters 
	// rather than RowsCollection.ColumnFilters.
	e.Layout.Bands[0].Override.AllowRowFiltering = DefaultableBoolean.True;
	e.Layout.Bands[0].Override.RowFilterMode = RowFilterMode.AllRowsInBand;

	// Set the AllowRowSummaries to either True or BasedOnDataType to allow
	// the user to be able to add, remove or modify summaries. This is not 
	// necessary to create summaries programmatically and only effects the 
	// users ability to create, remove or modify summaries.
	e.Layout.Bands[2].Override.AllowRowSummaries = AllowRowSummaries.BasedOnDataType;

	// You can also prevent the user from adding, removing or modifying a
	// summary on a column basis. This prevents the user from summarizing OrderID 
	// and ProductID columns.
	e.Layout.Bands[2].Columns["OrderID"].AllowRowSummaries = AllowRowSummaries.False;
	e.Layout.Bands[2].Columns["ProductID"].AllowRowSummaries = AllowRowSummaries.False;

	// Set the HeaderClickAction to SortMulti to allow the user to sort 
	// columns by clickin on the column headers.
	e.Layout.Override.HeaderClickAction = HeaderClickAction.SortMulti;

	// Set various appearances using Override. Override off the DisplayLayout sets 
	// grid-wide appearances while Override off individual bands sets the appearances
	// for that particular band.
	e.Layout.Override.CellAppearance.BackColor = Color.LightCyan;

	// You can override these for a specific band, in this case band 2.
	e.Layout.Bands[2].Override.CellAppearance.BackColor = Color.Beige;

	// You can also override appearance for individual columns.
	e.Layout.Bands[0].Columns["CustomerID"].CellAppearance.ForeColor = Color.Gray;

	// Set the CustomerID column's VisiblePosition to 0 so it's the first column
	// on the display.
	e.Layout.Bands[0].Columns["CustomerID"].Header.VisiblePosition = 0;

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also