/// <summary> /// Duplicate an existing field /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DuplicatePivotField_Click(object sender, EventArgs e) { int[] rows = FieldGridView.GetSelectedRows(); if (rows.Length == 0) { return; } PivotGrid.BeginUpdate(); object ds = PivotGrid.DataSource; PivotGrid.DataSource = null; PivotGridFieldMx f = PivotGrid.Fields[rows[0]] as PivotGridFieldMx; if (f == null) { return; } PivotGridFieldMx f2 = new PivotGridFieldMx(); f.CopyField(f2); PivotGrid.Fields.Add(f2); PivotGrid.DataSource = ds; PivotGrid.EndUpdate(); FillFieldDetailsGrid(); return; }
/// <summary> /// Delete the pivot fields corresponding to the currently selected rows in the field grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeletePivotField_Click(object sender, EventArgs e) { int[] rows = FieldGridView.GetSelectedRows(); if (rows.Length == 0) { return; } PivotGrid.BeginUpdate(); object ds = PivotGrid.DataSource; PivotGrid.DataSource = null; for (int ri = rows.Length - 1; ri >= 0; ri--) { PivotGrid.Fields.RemoveAt(rows[ri]); // delete pivot field from pivot grid control FieldGridView.DeleteRow(rows[ri]); // also from the field grid } PivotGrid.DataSource = ds; PivotGrid.EndUpdate(); return; }