Collection of columns.

Namespace: Dapfor.Wpf.Controls
Assembly: Dapfor.Wpf (in Dapfor.Wpf.dll) Version: 4.1.0.26317 (4.1.0.26317)

Syntax

C#
public sealed class ColumnCollection : IList<Column>, 
	ICollection<Column>, IEnumerable<Column>, IList, 
	ICollection, IEnumerable
Visual Basic
Public NotInheritable Class ColumnCollection
	Implements IList(Of Column), ICollection(Of Column), 
	IEnumerable(Of Column), IList, ICollection, IEnumerable
Visual C++
public ref class ColumnCollection sealed : IList<Column^>, 
	ICollection<Column^>, IEnumerable<Column^>, IList, 
	ICollection, IEnumerable
F#
[<SealedAttribute>]
type ColumnCollection =  
    class
        interface IList<Column>
        interface ICollection<Column>
        interface IEnumerable<Column>
        interface IList
        interface ICollection
        interface IEnumerable
    end

Remarks

A header is a collection of columns that enables displaying data in data grid's cells. A grid supports one or more headers. When a single header is used, the grid has TreeListView control behavior, just like the Microsoft Windows Explorer. Multiple headers enable separate column management for each hierarchical level. At a glance, every header consists of two panels: the grouping panel and the columns panel. These panels aren't related to each other. It means that the same column may be present in both panels simultaneously. Each column carries very important information about width, location, visibility, grouping and data sorting.

In programming, headers can be added to the grid by calling GridControl.Headers.Add(Header header) method. When a header is added to GridControl.Headers collection, a zero-based index is assigned to it in the hierarchy. When you call Header.Add(Column column) method, additional columns are added to a header. After that columns can be accessed with indexer operator. Every header has the following collections of columns:

The same column can be located in different lists. Almost each of the aforementioned lists has Clear() method, that has a specific action when invoked on a certain collection. Specifically, Header.GroupedColumns.Clear() removes data grouping in header of a grid. To group data you only have to set Column.Grouped property to true. If you set this property to true for multiple columns, it will result in multiple grouping and will fill corresponding collection in the data grid header. Such approach can be used in sorting (Column.SortDirection). The number of fixed columns is defined by Header.FixedColumns.Count.

XAML code example:

 Copy imageCopy
<df:GridControl x:Name="grid">
    <df:GridControl.Headers>
        <!-- Top-level header -->
        <df:Header>
            <df:Header.Columns>
                <df:Column Id="FirstName" Title="First Name"/>
                <df:Column Id="LastName" Title="Last Name" />
            </df:Header.Columns>
        </df:Header>

        <!-- Child header -->
        <df:Header>
            <df:Header.Columns>
                <df:Column Id="BookName" Title="Name" />
                <df:Column Id="BookGenre" Title="Genre" />
            </df:Header.Columns>
        </df:Header>
    </df:GridControl.Headers>
</df:GridControl>

The same can be done in the C# code:

 Copy imageCopy
public void MultipleHeaderGrid(GridControl grid)
{
    //Initialize the grid with two headers
    grid.Headers.Add(new Header());
    grid.Headers[0].Add(new Column("FirstName", "First Name"));
    grid.Headers[0].Add(new Column("LastName", "Last Name"));

    grid.Headers.Add(new Header());
    grid.Headers[1].Add(new Column("BookName", "Name"));
    grid.Headers[1].Add(new Column("BookGenre", "Genre"));
}

Inheritance Hierarchy

System..::..Object
  Dapfor.Wpf.Controls..::..ColumnCollection

See Also