How can 'Group By' on a ultrawingrid column?

Sunscreen picture Sunscreen · May 26, 2011 · Viewed 11.3k times · Source

On the control appears a feature saying 'Drag a column header to gorup by that column'. Can i do that programmatically. Are there any properties or do I need to embed SQL statements?

Thanks, Sun

Answer

Sebastian Piu picture Sebastian Piu · May 26, 2011

You need to add the column to the SortedColumns collection in the band:

    private void SwitchGroupByFor(string key) //key stands for the ultragridcolumn key
    {
        var band = grid.DisplayLayout.Bands[0];
        var sortedColumns = band.SortedColumns;

        sortedColumns.Add(key, false, true); //last flag indicates is a group by column
    }

hth