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...

    Here some sample code that you can try. There may be a better way to
    implement this, but this does seem to work.


    public static string GetDataFromEntireColumn(UltraGridRow currentRow,
    UltraGridCell currentCell, UltraGrid ultraGrid, bool includeHeader)
    {
    StringBuilder columnData = new StringBuilder();
    if (currentCell != null)
    {
    RowsCollection rows;
    if (currentRow.ParentRow == null)
    {
    rows = ultraGrid.Rows;
    }
    else
    {
    rows = currentRow.ParentRow.ChildBands[currentRow.Band].Rows;
    }

    foreach (UltraGridRow row in 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();
    }
Reply Children
No Data