Hello,
I want to copy multiple rows from excel and paste them to my grid. At my first copy action all off the rows are copied. but when i try to copy other rows, blank cells-rows are pasted to the grid. i have checked Clipboard.GetText(); but it is not empty.
I have a grid like below
the items source and the events in the grid is below
I want to copy multiple rows from excel and paste them to my grid. At my first copy action all off the rows are copied. but when i try to copy other rows, blank cells-rows are pasted to the grid. i have checked Clipboard.GetText(); but it is not empty.
I have a grid like below
<telerik:RadGridView AutoGenerateColumns="False" Margin="5" ShowGroupPanel="False" HorizontalAlignment="Left" Name="DataGridProducts" IsFilteringAllowed="False" ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PageUpdateProductMainFields}},Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Path=Products}" Pasting="DataGridProducts_Pasting" KeyDown="DataGridProducts_KeyDown"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Header="Malzeme Kodu" DataMemberBinding="{Binding ItemStockCode}" Width="150"/> <telerik:GridViewDataColumn Header="Malzeme Adı" DataMemberBinding="{Binding ItemName}" Width="150"/> <telerik:GridViewDataColumn Header="Alış Fiyatı" DataMemberBinding="{Binding IncomePrice}" Width="100"/> </telerik:RadGridView.Columns> </telerik:RadGridView>the items source and the events in the grid is below
private DynaList<Product> _Products;public DynaList<Product> Products{ get { if (_Products == null) _Products = new DynaList<Product>(); return _Products; } set { _Products = value; }}public void AddEmptyProduct(){ Product tempProduct = new Product(); Products.Insert(Products.Count, tempProduct);}private void DataGridProducts_Pasting(object sender, Telerik.Windows.Controls.GridViewClipboardEventArgs e){ string nodes1 = Clipboard.GetText(); string[] nodes2 = nodes1.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 1; i < nodes2.Count(); i += 1) { AddEmptyProduct(); }}private void DataGridProducts_KeyDown(object sender, System.Windows.Input.KeyEventArgs e){ if (e.Key == Key.RightShift) { DataGridProducts.CommitEdit(); AddEmptyProduct(); DataGridProducts.SelectedItem = DataGridProducts.Items[Products.Count - 1]; }}