Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: DataGridControl Speed Improvement Suggestions?

$
0
0
Hi,

Depending on which type of View you are using on the DataGridControl, there are two ways of setting the RowHeight for all rows.

For the TableView, simply set the Style of the DataRow elements to have the Height you need.

<Style TargetType="{x:Type xcdg:DataRow}">
<Setter Property="Height" Value="40" />
</Style>

For the TableflowView, set its ContainerHeight value to the desired height.

<xcdg:DataGridControl.View>
<xcdg:TableflowView ContainerHeight="40" />
</xcdg:DataGridControl.View>

Documentation onColumn width setting can be found here : http://doc.xceedsoft.com/products/XceedWpfDataGrid/Column_Positions_and_Widths.html

I've made a pretty simple sample : 60 rows and 35 columns of int. The Total loading time is always around 1.2 second :
<xcdg:DataGridControl x:Name="_dataGrid"
                            ItemsSource="{Binding MyData}" />
 public partial class MainWindow : Window
  {
    private int startTick;

    public MainWindow()
    {
      startTick = Environment.TickCount;

      InitializeComponent();

      this.MyData = new ObservableCollection<MyObject>();
      for( int i = 0; i < 60; ++i )
      {
        this.MyData.Add( new MyObject( i + 1 ) );
      }

      _dataGrid.DataContext = this;

      this.Loaded += this.MainWindow_Loaded;
    }

    public ObservableCollection<MyObject> MyData
    {
      get;
      set;
    }

    private void MainWindow_Loaded( object sender, RoutedEventArgs e )
    {
      int endTick = Environment.TickCount;
      System.Diagnostics.Debug.WriteLine("TOTAL TICKS = {0}", endTick - startTick);
    }
  }

  public class MyObject
  {
    public MyObject( int start )
    {
      this.One = start * 1;
      this.Two = start * 2;
      this.Three = start * 3;
      this.Four = start * 4;
      this.Five = start * 5;
      this.Six = start * 6;
      this.Seven = start * 7;
      this.Eight = start * 8;
      this.Nine = start * 9;
      this.Ten = start * 10;
      this.Eleven = start * 11;
      this.Twelve = start * 12;
      this.Thirteen = start * 13;
      this.Fourteen = start * 14;
      this.Fifteen = start * 15;
      this.Sixteen = start * 16;
      this.Seventeen = start * 17;
      this.Eighteen = start * 18;
      this.Nineteen = start * 19;
      this.Twenty = start * 20;
      this.TwentyOne = start * 21;
      this.TwentyTwo = start * 22;
      this.TwentyThree = start * 23;
      this.TwentyFour = start * 24;
      this.TwentyFive = start * 25;
      this.TwentySix = start * 26;
      this.TwentySeven = start * 27;
      this.TwentyEight = start * 28;
      this.TwentyNine = start * 29;
      this.Thirty = start * 30;
      this.ThirtyOne = start * 31;
      this.ThirtyTwo = start * 32;
      this.ThirtyThree = start * 33;
      this.ThirtyFour = start * 34;
      this.ThirtyFive = start * 35;
    }

    public int One { get; set; }
    public int Two { get; set; }
    public int Three { get; set; }
    public int Four { get; set; }
    public int Five { get; set; }
    public int Six { get; set; }
    public int Seven { get; set; }
    public int Eight { get; set; }
    public int Nine { get; set; }
    public int Ten { get; set; }
    public int Eleven { get; set; }
    public int Twelve { get; set; }
    public int Thirteen { get; set; }
    public int Fourteen { get; set; }
    public int Fifteen { get; set; }
    public int Sixteen { get; set; }
    public int Seventeen { get; set; }
    public int Eighteen { get; set; }
    public int Nineteen { get; set; }
    public int Twenty { get; set; }
    public int TwentyOne { get; set; }
    public int TwentyTwo { get; set; }
    public int TwentyThree { get; set; }
    public int TwentyFour { get; set; }
    public int TwentyFive { get; set; }
    public int TwentySix { get; set; }
    public int TwentySeven { get; set; }
    public int TwentyEight { get; set; }
    public int TwentyNine { get; set; }
    public int Thirty { get; set; }
    public int ThirtyOne { get; set; }
    public int ThirtyTwo { get; set; }
    public int ThirtyThree { get; set; }
    public int ThirtyFour { get; set; }
    public int ThirtyFive { get; set; }
  }
10 seconds for 35 columns is way too long. Can you submit some code to see how you do it ? Or is the data obtained from an extern database with long data access ?

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>