Gets or sets a value indicating whether this Column is grouped.

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

Syntax

C#
public bool Grouped { get; set; }
Visual Basic
Public Property Grouped As Boolean
	Get
	Set
Visual C++
public:
property bool Grouped {
	bool get ();
	void set (bool value);
}
F#
member Grouped : bool with get, set

Property Value

Type: Boolean
true if grouped; otherwise, false.

Remarks

GridControl enables multiple data grouping in headers of the GridControl by any columns at any hierarchical level. When data is grouped by a specific column, GridControl searches all rows within a group that has similar values. When a group is organized, a row that doesn't contain a data object is added to the data grid. The Row.IsGroup property of such row will always return true, and Row["column id"].Value will return a value by which data is grouped. All rows with values that meet grouping conditions are attached to the newly created group. Before a new data object is added, GridControl verifies whether there is any group with the required value on the current hierarchical level. If there is no such group, a new group is created. When the Row.Update() method is invoked, the grid checks whether a row conforms to group value. If there are no more rows in the group, the group is removed from the grid.

In programming the grouping feature can be enabled via the Column.Grouped property. Sequential invocation of this property for several columns results in data grouping of these columns. The column with grouping remains visible unless Column.Visible property is set to false. Sorting (and multiple sorting) can be enabled or disabled for grouped columns because sorting and grouping are completely independent processes. The list of grouped columns can be viewed with Header.GroupedColumns collection property. A user can also group columns in the data grid. To use this ability the user just needs to drag a column to a special panel on the grid's header. However, this is not possible if height of this panel is set to 0.

When grouping and filtering are enabled simultaneously, the GridControl checks every group for visible rows. If there are no visible rows, the group is filtered. If a single unfiltered row appears, the row of the group also becomes visible.

 Copy imageCopy
public void GroupedColumnsExample(GridControl grid)
{
    //Add a new header on the top hierarchical level (level 0)
    Header header = new Header();
    header.Add(new Column("Column1"));
    header.Add(new Column("Column2"));
    header.Add(new Column("Column3"));
    grid.Headers.Add(header);

    Console.WriteLine("Grouped columns count: {0}", header.GroupedColumns.Count);

    header["Column1"].Grouped = true;
    header["Column3"].Grouped = true;
    Console.WriteLine("Columns count: {0}", header.Count);
    Console.WriteLine("Grouped columns count: {0}", header.GroupedColumns.Count);

    //Move the last grouped column to the upper level
    header.GroupedColumns[1].GroupIndex = 0;

    //Iterate all grouped columns
    foreach (Column column in header.GroupedColumns)
    {
        Console.WriteLine("Grouped column: id = '{0}', index = {1}, group index = {2}, visible index = {3}", column.Id, column.Index, column.GroupIndex, column.VisibleIndex);
    }

    //Ungroup all columns
    header.GroupedColumns.Clear();
    Console.WriteLine("Columns count: {0}", header.Count);
    Console.WriteLine("Grouped columns count: {0}", header.GroupedColumns.Count);
}

//Console output:
Grouped columns count: 0
Columns count: 3
Grouped columns count: 2
Grouped column: id = 'Column3', index = 2, group index = 0, visible index = 2
Grouped column: id = 'Column1', index = 0, group index = 1, visible index = 0
Columns count: 3
Grouped columns count: 0

See Also