Search code examples
c#wpftelerikradgridview

Copy cell content to clipboard RadGridView WPF


I'm working in RadGridView where i need to copy the cell content.

As part of the application functionality, i want the Grid SelectionUnit to always be of type Row. In addition to this, we also want to expose a mechanism where the user can select a cell value for copy to clipboard.

Is there a way to do this? For example, double clicking a cell copies the cell value where as single click always selects the row.


Solution

  • Try this,

    Not a perfect one, but for your requirement it suits.

    void testGridView_CopyingCellClipboardContent(object sender, GridViewCellClipboardEventArgs e)
    {
        if (grdName.CurrentCell != null && grdName.CurrentCell.Column == e.Cell.Column)
        {
            e.Cancel = false;
        }
        else
            e.Cancel = true;
    }
    

    Where replace your GridView name with "grdName".