We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Performance of adding GridBoundColumns

Thread ID:





2283 Dec 30,2002 09:31 PM UTC Dec 30,2002 10:31 PM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On December 30, 2002 09:31 PM UTC

I'm using a GridDataBoundGrid to display the results of a user-issued query. I loop through the result set and add a GridBoundColumn for each column, set the CellType to Static and in the case of datetime columns, I set the format. When a different query is issued, a new DataSet is created to hold the results, but the same grid is used for presentation. This is when I run into problems. The first time I generate the GridBoundColumns the process takes about 1 second for 24 columns. On subsequent iterations, the time to generate 24 columns increases to 10 or more seconds. I'm using the code below: m_dgResultGrid.SuspendLayout(); m_dgResultGrid.Binder.SuspendBinding(); m_dgResultGrid.Model.SuspendChangeEvents(); m_dgResultGrid.DataSource = null; m_dgResultGrid.GridBoundColumns.Clear(); DateTime dtBegin = DateTime.Now; foreach(DataColumn dc in dataSet.Tables[0].Columns) { GridBoundColumn gbc = new GridBoundColumn(); gbc.MappingName = dc.ColumnName; gbc.HeaderText = dc.ColumnName; if(dc.DataType == typeof(DateTime)) { gbc.StyleInfo.Format = "g"; } gbc.StyleInfo.CellType = "Static"; m_dgResultGrid.GridBoundColumns.Add(gbc); } TimeSpan ts = DateTime.Now - dtBegin; Debug.WriteLine(string.Format("Time to generate columns: {0}", ts.TotalMilliseconds)); // set the datasource m_dgResultGrid.Binder.ResumeBinding(); m_dgResultGrid.ResumeLayout(); m_dgResultGrid.Model.ResumeChangeEvents(); Any thoughts on why I'm seeing this behavior? Sean

Administrator [Syncfusion]
Replied On December 30, 2002 10:25 PM UTC

Sean, try creating a GridBoundColumn[] array and then call GridBoundColumnsCollection.AddRange with that array. That way the grid will have not to reinitialize all columns after each Add call. Stefan

Sean Greer
Replied On December 30, 2002 10:31 PM UTC

Stefan, Thanks for the suggestion - it resolved the issue. The time to update the columns is now closer to .3 seconds, which is quite acceptable. Sean


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon