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
160
UltraWinGrid: single copy (row/cell) , multi paste
posted

It is possible in ultrawinGrid, select one cell , performing  Me.UltraGrid1.PerformAction(UltraGridAction.Copy), and then paste the value in multiselected cells?Does exist a buit-in feature? If i use Me.UltraGrid1.PerformAction(UltraGridAction.Paste) , the value is copied only in the last active cell. I'd like that the value is copied into all selected cells.

Riccardo

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi Riccardo,

    There's nothing built-in to the grid to do this. But you could modify the grid's behavior using the BeforeMultiCellOperation event. Here's a very simple example of how you might go about it. This doesn't account for nulls or data type mismatches or other errors, it's just something I threw together very quickly. But it should point you in the right direction.


            private void ultraGrid1_BeforeMultiCellOperation(object sender, BeforeMultiCellOperationEventArgs e)
            {
                UltraGrid grid = (UltraGrid)sender;
                if (e.Operation == MultiCellOperation.Paste)
                {
                    if (e.Cells.ColumnCount == 1 &&
                        e.Cells.RowCount == 1)
                    {
                        object newValue = e.NewValues[e.Cells[0, 0]].Value;
                        foreach (UltraGridCell cell in grid.Selected.Cells)
                        {
                            cell.Value = newValue;
                        }
                        e.Cancel = true;
                    }
                }
            }

Children