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
2320
Copy and paste when grid is readonly
posted

How can I make an XamGrid be readonly while at the same time letting the user select a cells contents so they can copy and paste values?  I.e, grid is readonly, but they need to be able to select a cells value, copy and paste it into another app.

If I set

<ig:XamGrid.EditingSettings>
  <ig:EditingSettings AllowEditing="Cell" IsMouseActionEditingEnabled="SingleClick"
IsEnterKeyEditingEnabled
="True" IsF2EditingEnabled="True"
IsOnCellActiveEditingEnabled
="False" />
</ig:XamGrid.EditingSettings>

I set these editing settings to make it so you can select on an individual cell.
I also set the columns IsReadOnly to true but once you do this, you can't select
the cell's value.

Any help would be greatly appreciated.

Thanks in advance.


Parents
No Data
Reply
  • 2320
    posted

    The only ways I could figure out how to lets the user select and copy the data in a cell from a readonly grid was to either template every column in XAML with readonly textbox's (which looked odd and would of required additional styling) or to just add a right-click context menu option called copy and use the grids ActiveCell property like such...

    try
    {
    if (grid.ActiveCell != null)
       Clipboard.SetText(grid.ActiveCell.Value.ToString());
    }
    catch(System.Security.SecurityException)
    {
    // user selected no, handle silently.
    }

    I was hoping there was a property I was missing or something that would allow
    the user to select a cell's contents when the grid columns are readonly. I
    even tried messing with a couple events hoping I could just abort an event
    but non of them worked appropriately for me.

Children