jun1lee-3451 avatar image
0 Votes"
jun1lee-3451 asked HuiLiu-MSFT commented

Is there a way to speed up when copying WPF DataGrid with many rows?

I have created a program that shows SQL DB and shows it on the DataGrid.
Originally, someone was made of Winform, but it was newly made with WPF for improvement.
If I look up the SQL DB, about 18,000 rows are inquired.
While working, I sometimes copy all rows to Ctrl+C, but the DataGrid stops completely after being too slow and choosing.
There are so many rows that seem to be overloaded.
However, if I look up the same SQL DB with the existing program Winform and copy it, I can copy it in 1 second and paste it with Excel very quickly.
I want to implement this behavior as WPF DataGrid, but I don't know a good way. Who can help me? In addition, attach XAML.
And I don't have winform code someone made.

 <DataGrid x:Name="dg_tr" ItemsSource="{Binding}" AutoGenerateColumns="False" 
                                     FontSize="12" Margin="10 10 5 0"                         
                                     Width="850" Height="500"
                                     RowHeaderWidth ="NaN"
                                     ClipboardCopyMode="{Binding ElementName=chk_header_copy, Path=IsChecked, Converter={StaticResource dg_CopyHeaderCopyModeConverter}}"
                                     GridLinesVisibility="All" HorizontalGridLinesBrush="LightGray"
                                 <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="{x:Static SystemColors.HighlightColor}"/>
                                 <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="{x:Static SystemColors.HighlightTextColor}"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col1}" Header="col1"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col2}" Header="col2"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col3}" Header="col3"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col4}" Header="col4"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col5}" Header="col5"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col6}" Header="col6"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col7}" Header="col7"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col8}" Header="col8"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col9}" Header="col9"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col10}" Header="col10"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col11}" Header="col11"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col12}" Header="col12"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col13}" Header="col13"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col14}" Header="col14"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col15}" Header="col15"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col16}" Header="col16"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col17}" Header="col17"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col18}" Header="col18"/>
                                 <DataGridTextColumn Binding = "{Binding Path = col19}" Header="col19"/>

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

would need to see the code for dg_CopyHeaderCopyModeConverter

0 Votes 0 ·

This is code.

 public class dg_CopyHeaderCopyModeConverter : IValueConverter
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
             bool _bool = (bool)value;
             return _bool ? DataGridClipboardCopyMode.IncludeHeader : DataGridClipboardCopyMode.ExcludeHeader;
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
             throw new NotSupportedException();
0 Votes 0 ·

Hi,@ jun1lee-3451 . Has the problem been solved? Or is there any update? If not, is it possible to provide detailed code?

0 Votes 0 ·

Hi,@ jun1lee-3451 . What is the code of the data source that your DataGrid is bound to? Could you show your complete code related to dg_tr_recipe_LoadingRow and dg_tr_recipe_PreviewMouseDoubleClick ?

0 Votes 0 ·

0 Answers