void UpdateTotals()
{
  // no repainting until we're done
  _flex.Redraw = false;
  
  // clear old subtotals, if any
  _flex.Subtotal(AggregateEnum.Clear);
  
  // sort the grid on the columns that will be grouped
  _flex.Sort(SortFlags.Ascending, 0, 3);
  
  // show outline tree on column 0
  _flex.Tree.Column = 0;
  
  // get a grand total (use -1 instead of column index)
  _flex.Subtotal(AggregateEnum.Sum, -1, -1, 3, "Grand Total");
  
  // total on column 0 (initially Product)
  _flex.Subtotal(AggregateEnum.Sum, 0, 0, 3);
  
  // total on column 1 (initially Region)
  _flex.Subtotal(AggregateEnum.Sum, 1, 1, 3);
  
  // show outline level 1
  _flex.Tree.Show(1);
  
  // restore painting
  _flex.Redraw = true;
}
void _flex_AfterDragColumn(object sender, DragRowColEventArgs e)        
{
  UpdateTotals(); // user moved a column, update totals
}