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

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)