First, even if the Grid is set with SelectionUnit="FullRow" SelectionMode="Single", after a paste occurs the top row where the data was pasted remains selected. I can then select another row, ending up with multiple-rows selected. Subsequent pastes start at the top-most selected row, even if it's not the most recently selected row. Therefore, in addition to a very strange display (with multiple rows selected and no apparent way to unselect them), you can never paste data into rows below where you have previously pasted data.
The second issue is that the InsertNewRows value of GridViewClipboardPasteMode no longer appears to be present, such that pasting data when not enough rows exist to accommodate truncates the paste.
For reference, the options I'm using are:
<telerik:RadGridView Grid.Row="0" x:Name="HistoricalGridView" AutoGenerateColumns="False" ItemsSource="{Binding Path=HistoricalData}" IsFilteringAllowed="False" ShowGroupPanel="False" CanUserSortColumns="False" ClipboardPasteMode="OverwriteWithEmptyValues,Cells" SelectionUnit="FullRow" SelectionMode="Single" >
Thanks for your help on these.
Louis
5 Answers, 1 is accepted
I tried to reproduce the issues you reported but to no avail. Attached you can find the project used for the test. Are you able to get the problems on it? Could you also specify the version of RadControls for WPF you are currently using?
Regards,
Vera
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

Here's a very simple code sample that you can use to recreate the problem (it exhibits it even with the dlls you supplied in your project):
XAML:
<
Window
x:Class
=
"CutPaste.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Grid
>
<
telerik:RadGridView
Grid.Row
=
"0"
x:Name
=
"HistoricalGridView"
AutoGenerateColumns
=
"False"
ItemsSource
=
"{Binding Path=HistoricalData}"
IsFilteringAllowed
=
"False"
ShowGroupPanel
=
"False"
CanUserSortColumns
=
"False"
ClipboardPasteMode
=
"OverwriteWithEmptyValues,Cells"
SelectionUnit
=
"FullRow"
SelectionMode
=
"Single"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=Time}"
DataFormatString
=
"{} {0:dd, MMM, yyyy}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=Rate}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
Grid
>
</
Window
>
Code-Behind:
using
System;
using
System.Windows;
using
System.Collections.ObjectModel;
namespace
CutPaste
{
public
struct
Data
{
public
DateTime Time {
get
;
set
; }
public
double
Rate {
get
;
set
; }
}
public
partial
class
MainWindow : Window
{
public
ObservableCollection<Data> HistoricalData {
get
;
set
; }
public
MainWindow()
{
HistoricalData =
new
ObservableCollection<Data>();
for
(
int
i = 0; i < 15; i++) {
HistoricalData.Add(
new
Data() { Time =
new
DateTime(2013 + i, 1, 1), Rate = 100 * i });
}
InitializeComponent();
DataContext =
this
;
}
}
}
Thanks again,
Louis
Actually, that would be the expected behavior when you work with struct. Selection counts on hash code and Equals method to differentiate the items and when you paste one over the other, all its values are the same and they become equal. You will get the same behavior if you just edit the item so that two items have absolutely the same values.
You can test that behavior on DataGrid as well.
Maya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

Edit: That also doesn't explain why pasting multiple rows into the bottom-most row doesn't append new rows.
Thanks,
Louis
Actually, there will be a bunch of cases where RadGridView (and DataGrid as well) will not work as expected when items are of type struct since this is value type rather than reference. You can test for example editing an item with DataGrid - once you refresh the collection by sorting for instance, you will see that the item the modified value is reverted to its previous one. Furthermore, selection will not work correctly as well since it counts on hash code and Equals method.
My recommendation would be to work with a reference type instead and, thus being able to benefit from all the features RadGridView provides.
Maya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>