Home Forums WinForms controls Xceed Grid for WinForms DateTime? as DataType slow down the grid

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17321 |

    We use a Grid of about 40 columns and 250 rows. 10 of them are of type DateTime? at the right end of the grid.

    When we scroll to the right the grid the grid takes more time to refresh it’s state.  Same behaviour, if we use the up and down arrow to navigate between the rows.  If I change the datatype of the DateTime? columns to string and set the value of the cell to date.ToString(), the grid scrolls fluently again. 

    Any idea to how I could use DateTime? type and keep the speed of the grid ?

    Imported from legacy forums. Posted by Martin (had 2220 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    It’s the first time I’m hearing about this.  There shouldn’t be any noticeable difference when it comes to the refresh rate when comparing the rendering of a string and DateTime.   

    Regards,

    Imported from legacy forums. Posted by Ghislain (had 335 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi again,

    well, a co-worker who has logged many hours in the programming of the Grid for .NET is curious to see a repro-app.  So, if you can manage something (self-contained application, no bin, no obj folders) and send it to support@xceed.com, go ahead.  We will take a look.  Thank you.  And, if possible, tell us about the development setup: version of Windows, format in which your DateTime is displayed, which language, etc.  Which version of the Grid for .NET you’re using?

    Imported from legacy forums. Posted by Ghislain (had 315 views)

    User (Old forums)
    Member
    Post count: 23064

    Just made a simple Windows Form Application and filled the Form1 constructor with this code.  In the resulting application, you’ll have 2 tabs, each one containing a grid. The first one has DateTime? columns on the right, the other dont.  Just switching from one tab to the other makes the Grid containing dates go slow.  You can also scroll to the right, select a cell and move up or down with the up/down keys on the keyboard and you’ll see that it takes more time on the grid with dates. Clicking on different rows, while the dates are displayed also shows a little delay between the click and the row being hightlighed

    Configuration :

    Windows XP SP2 francais, Core 2 Quad Q9550, 4 Mb Ram, 10 000 RPM hard drive, VS2008, Version 3.8.9460.14460 of the Grid
     


    public partial class Form1 : Form {
            public Form1() {
                TabControl tabControl = new TabControl();
                TabPage    tabPage1 = new TabPage();
                TabPage tabPage2 = new TabPage();
                Xceed.Grid.GridControl grid1 = new Xceed.Grid.GridControl();
                Xceed.Grid.GridControl grid2 = new Xceed.Grid.GridControl();

                tabPage1.Text = "Avec dates";
                tabPage2.Text = "Sans dates";

                InitializeComponent();
                

                for (int i = 0; i < 30; i++ ) {
                    grid1.Columns.Add(new Column(string.Format("String {0}", i), typeof(String)));
                }
                for (int i = 0; i < 10; i++) {
                    grid1.Columns.Add(new Column(string.Format("DateTime {0}", i), typeof(DateTime?)));
                }
                for (int i = 0; i < 40; i++) {
                    grid2.Columns.Add(new Column(string.Format("String {0}", i), typeof(String)));
                }

                tabPage1.Dock = DockStyle.Fill;
                tabPage2.Dock = DockStyle.Fill;
                grid1.Dock = DockStyle.Fill;
                grid2.Dock = DockStyle.Fill;
                tabControl.Dock = DockStyle.Fill;

                tabPage1.Controls.Add(grid1);
                tabPage2.Controls.Add(grid2);

                tabControl.TabPages.Add(tabPage1);
                tabControl.TabPages.Add(tabPage2);

                Controls.Add(tabControl);
                ColumnManagerRow columnManagerRow = new ColumnManagerRow();
                grid1.FixedHeaderRows.Add(columnManagerRow);

                for (int i=0; i < 250; i++) {
                    DataRow row = grid1.DataRows.AddNew();
                    row.BeginEdit();
                    for (int j=0; j < grid1.Columns.Count;j++) {
                        if (grid1.Columns[j].DataType.Equals(typeof(String))) {
                            row.Cells[j].Value = string.Format("Value [{0},{1}]", i, j);
                        }
                        if (grid1.Columns[j].DataType.Equals(typeof(DateTime?))) {
                            row.Cells[j].Value = DateTime.Now.AddDays((grid1.Columns.Count*i) + j);
                        }
                    }
                    row.EndEdit();
                }

                for (int i = 0; i < 250; i++) {
                    DataRow row = grid2.DataRows.AddNew();
                    row.BeginEdit();
                    for (int j = 0; j < grid2.Columns.Count; j++) {
                        if (grid2.Columns[j].DataType.Equals(typeof(String))) {
                            row.Cells[j].Value = string.Format("Value [{0},{1}]", i, j);
                        }
                    }
                    row.EndEdit();
                }

            }
        }

    Imported from legacy forums. Posted by Martin (had 292 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    I will look at this next week. 

    Best regards,

    Imported from legacy forums. Posted by Ghislain (had 513 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Martin,

    We forgot to consider a thing or two. 

    Writing a variable of type DateTime to memory will always be much slower than writing a string since a string can be stored/retrieved directly while a DateType needs to be converted AND boxed as an object.  Reading back a DateTime variable requires 1) unboxing of the object which contains the DateTime structure.  2) conversion of the DateTime variable into something viewable in a given format.

    Best regards,

    Imported from legacy forums. Posted by Ghislain (had 1651 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.