using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Infragistics.Win.UltraWinGrid;

namespace _139970
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("group", typeof(string));
            dt.Columns.Add("price", typeof(int));

            for (int i = 0; i < 100; i++)
            {
                dt.Rows.Add(string.Format("Group{0}", i % 9), i % 5);
            }

            ultraGrid1.DataSource = dt;
        }

        private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
           
            e.Layout.Bands[0].Columns[0].GroupByComparer = new Comparer();
            e.Layout.Override.HeaderPlacement = HeaderPlacement.FixedOnTop;
            e.Layout.Override.GroupBySummaryDisplayStyle = GroupBySummaryDisplayStyle.SummaryCells;
            e.Layout.Override.SummaryDisplayArea = SummaryDisplayAreas.GroupByRowsFooter | 
                SummaryDisplayAreas.InGroupByRows ;
       
           
            e.Layout.Bands[0].SortedColumns.Add("group", true, true);
            SummarySettings ss = e.Layout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Sum, e.Layout.Bands[0].Columns["price"], Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn);
            ss.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows;
        }
    }
}
