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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid performance when setting values

Thread ID:





28031 Apr 21,2005 09:50 PM UTC Apr 22,2005 06:29 PM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On April 21, 2005 09:50 PM UTC

Hi there, I have a simple application that host the grid control, with about 1000 rows x 20 columns. I am looping through each cell and set its value. I try do do it in two different ways, 1) m_gird[nRow, nCol].Text = "abc"; 2) m_grid[nRow, nCol].CellValue = "abc"; it looks like (2) is faster than (1). However, I only interested in setting the cell''s value. Why is OnStyleChanged needed to be sent out? I am using Rational Quantify to do some profiling, and I see alot of time is spent in the GridStyleInfo.OnStyleChanged(..) when I am only setting the cell value. Is the function OnStyleChanged need to be executed when I only changing the text? Anyway, is there a more efficient way to change the cell text for the grid control? I am getting a couple seconds of delay when I initialize the grid in the constructor of my application. thanks, -patrick

Administrator [Syncfusion]
Replied On April 21, 2005 10:20 PM UTC

You can directly access the GridData object instead of using an indexer on the grid. This will avoid events and probably be a factor of 5 - 10 times faster.
private void button1_Click(object sender, System.EventArgs e)
	int nRows = 8500;
	int nCols = 25;
	Random r = new Random();
	this.Cursor = Cursors.WaitCursor;
	int ticks = Environment.TickCount;
	this.gridControl1.RowCount = nRows;
	this.gridControl1.ColCount = nCols;
	GridData data = this.gridControl1.Data;
	for(int i = 1; i <= nRows; ++i)
		for(int j = 1; j <= nCols; ++j)
			// instead of      this.gridControl1[i,j].CellValue = ????
			//use this code
			GridStyleInfo style = new GridStyleInfo();
			style.CellValue = r.Next(100000);
			data[i, j] = style.Store;
	this.Cursor = Cursors.Default;
	this.label1.Text = string.Format("{0} ticks", Environment.TickCount - ticks);

Administrator [Syncfusion]
Replied On April 22, 2005 06:29 PM UTC

Thanks, it helps a lot. -patrick


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

or the page will be automatically redirected to 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