Click here to Skip to main content
15,885,908 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how to set wpf datagrid rendering fast for large data? help with me.

Search button click event
C#
private void Search_Click(object sender, RoutedEventArgs e)
{
try
{
 
dgMMSize.ItemsSource = _mmsize.GetMMSize(txtId.Text);
}
catch (Exception ex)
{
if (stack.ToLower() == "true")
logService.Error(ex.ToString());
else
logService.Error(ex.Message.ToString());
 
MessageBox.Show(ex.Message);
}
}


Search click takes 16 sec before any data is showing.
Posted
Updated 14-Aug-14 2:40am
v2
Comments
Kim Togo 14-Aug-14 2:52am    
How much data, 1000, 10.000, 1.000.000 items?
Are you doing any WPF styling or are you using Grouping for the DataGrid?
sureshsankar 14-Aug-14 5:06am    
any example code?
Kim Togo 14-Aug-14 5:10am    
Show the WPF XAML where you put in the ItemSource and the layout for your WPF DataGrid.
Kim Togo 14-Aug-14 5:11am    
Just hit "Improve question" and update with example code
sureshsankar 14-Aug-14 8:28am    
Search button click event

private void Search_Click(object sender, RoutedEventArgs e)
{
try
{

dgMMSize.ItemsSource = _mmsize.GetMMSize(txtId.Text);
}
catch (Exception ex)
{
if (stack.ToLower() == "true")
logService.Error(ex.ToString());
else
logService.Error(ex.Message.ToString());

MessageBox.Show(ex.Message);
}
}

1 solution

How long time does it take to get data in "_mmsize.GetMMSize(txtId.Text)" ?

Change you code to:
C#
System.Diagnostics.Stopwatch t1 = System.Diagnostics.Stopwatch.StartNew();
var data = _mmsize.GetMMSize(txtId.Text);
t1.Stop();
MessageBox.Show(t1.Elapsed);

t1.Restart();
dgMMSize.ItemsSource = data;

t1.Stop();
MessageBox.Show(t1.Elapsed);


Perhaps it is a search in SQL ?

Normal in WPF, you only set ItemsSource one time and uses Filter functions to tell what data DataGrid has to show.

My guess is that "_mmsize.GetMMSize" is doing a SQL search and returns an array or list of data ?
 
Share this answer
 
v2
Comments
sureshsankar 14-Aug-14 9:55am    
list
sureshsankar 14-Aug-14 10:01am    
i am used list of data
sureshsankar 14-Aug-14 10:21am    
how set fast load in datagrid
Kim Togo 15-Aug-14 3:02am    
How long does it takes to get all the data in "_mmsize.GetMMSize(txtId.Text);" ?
sureshsankar 16-Aug-14 1:44am    
more then 15 sec

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900