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
170
Copy all values in a column.
posted

I am trying to implement "Copy selected column" using context menu. Following code works fine in a plain grid but when a band is introduced it fails. Is there any other way I can implement this functionality?

        public static string GetDataFromEntireColumn(UltraGridCell currentCell, UltraGrid grid, bool includeHeader)
        {
            StringBuilder columnData = new StringBuilder();
            if (currentCell != null)
            {
                foreach (UltraGridRow row in grid.Rows)
                {
                    columnData.Append( row.Cells[currentCell.Column.Key].Text + Environment.NewLine);
                }
                if (includeHeader)
                {
                    columnData.Insert(0,currentCell.Column.Header.Caption + Environment.NewLine);
                }
            }
            return columnData.ToString();
        }

Thanks in advance

Parents
  • 135
    Offline posted
    In article , bnmerch says...

    Is it failing when the currentCell is a cell in a child band?

    If so, then you'll need to use the ChildBands collection of the parent
    row and loop through the correct child band's row collection.

    Your current foreach loop is looping through the parent rows in the
    grid.

    HTH

    John
Reply Children