This is a migrated thread and some comments may be shown as answers.

Empty RadGridView breaking on paste

1 Answer 138 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 20 Feb 2013, 05:27 PM
RadGridView breaks when you have no data in it and you try and paste. I get a DataGrid_DisplayIndexOutOfRange exception. Here is an example: 

<Window x:Class="TestTablePaste.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                Title="MainWindow" Height="350" Width="525">
   <Grid>
        <telerik:RadGridView>
            <telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu>
                    <telerik:RadMenuItem Header="Paste" Command="ApplicationCommands.Paste"></telerik:RadMenuItem>
                </telerik:RadContextMenu>
            </telerik:RadContextMenu.ContextMenu>
        </telerik:RadGridView> 
    </Grid>
</Window>

I was wondering if this is a known issue and if there was a work around.

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 25 Feb 2013, 01:58 PM
Hi Eric,

I have already answered your ticket containing the same question. However, I will post my answer here as well in case anyone experience the same behavior:

Actually, this would be an expected behavior, because by design RadGridView throws this exception in order to handle an invalid cases (in this situation, the exception is thrown in order to notify you that you can not paste in a column which does not exist). 

In order to prevent this behaviour, you can handle the event that corresponds to the Paste command (Pasting event of the RadGridView). You could cancel it and then execute any additional logic in it.




Greetings,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Eric
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or