Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
545
Mark all Cells with "Ctrl" + "A" & "Ctrl" + "C", Infragistics 14.1
posted

I have a small problem with copy xamPivotGrid data by using Ctrl + C.

To Copy all data from xamPivotgrid I'm using a KeyDown event on xamPivotGrid.

pivotGrid.KeyDown += (s, e) =>
{
    if (e.Key == Key.C && (ModifierKeys.Control == Keyboard.Modifiers))
    {
        if (pivotGrid.SelectionSettings.SelectedRows.Count > 0)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("\t" + String.Join("\t", pivotGrid.SelectionSettings.SelectedRows.FirstOrDefault().Cells.Select(cell => cell.DataColumn.HeaderText)));
            foreach (var Item in pivotGrid.SelectionSettings.SelectedRows)
            {
                sb.AppendFormat("{0}\t", Item.HeaderText.Replace("\r\n", " "));
                sb.AppendFormat("{0}\n", String.Join("\t", Item.Cells.Select(a =>
                {
                    ICell Cell = (a.Data as ICell);
                    return Cell == null ? String.Empty : (a.Data as ICell).FormattedValue;
                })));
            }
            Clipboard.SetText(sb.ToString());
        }
    }
    if (e.Key == Key.A && ModifierKeys.Control == Keyboard.Modifiers)
    {
        foreach (Infragistics.Controls.Grids.PivotDataRow Row in pivotGrid.DataRows)
        {
            pivotGrid.SelectionSettings.SelectedRows.Add(Row);
        }
    }
};

The Problem is, I do not to Focus the Pivot Grid. If Pivot Grid is not focused, user cannot perform Mark + Copy. And the focus works only if I'm using TAB key. Usually a click on control element should be enough to set the focus. Is there any easy way to perform copy of table?

wbr

Roman