Possible to paste a single value across multiple cells?

2 posts, 1 answers
  1. LT
    LT avatar
    11 posts
    Member since:
    Oct 2018

    Posted 06 Mar 2019 Link to this post

    In Excel, holding onto a single value, you can paste it across all cells of a rectangle that you draw. I would like to duplicate this behavior with radGridView. Is it possible? I have tried it in my own program but it doesn't seem that the value is pasted across all cells selected, just the first one that was clicked on.

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4086 posts

    Posted 07 Mar 2019 Link to this post


    The described behavior is supported by RadSpreadsheet that the Telerik UI for WinForms suite offers. You can select a cell in the spreadsheet, right click to select Copy. Then, select a cells region, right click and select Paste. Thus, the copied value will be pasted among the selected cells.

    As to the RadGridView, it allows pasting over a single cell. If you need to affect all selected cells with the copied value, it would be necessary to handle the Pasting event and perform the desired action. A sample approach is demonstrated in the following code snippet:

    public RadForm1()
        for (int i = 0; i < 3; i++)
            this.radGridView1.Columns.Add("Col" + i);
        for (int i = 0; i < 10; i++)
            this.radGridView1.Rows.Add("Data" + i + ".0", "Data" + i + ".1", "Data" + i + ".2");
        this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
        this.radGridView1.MultiSelect = true;
        this.radGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;
        this.radGridView1.Pasting += radGridView1_Pasting;
    private void radGridView1_Pasting(object sender, Telerik.WinControls.UI.GridViewClipboardEventArgs e)
        e.Cancel = true;
        if (e.Format == "Text")
            string data = Clipboard.GetData(DataFormats.Text).ToString();
            if (data != null)
                foreach (GridViewCellInfo cell in this.radGridView1.SelectedCells)
                    cell.Value = data;

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top