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


Thread ID:





22472 Dec 14,2004 09:06 AM UTC Dec 14,2004 11:59 AM UTC WinForms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On December 14, 2004 09:06 AM UTC

Can you explain the functionality of PopulateValues function of essential grid? I have an array with 10 rows and 12 columns as the data source. What I want is that in my gridcontrol i should write all the ten rows but columns only from 2 to 9. That is the column 2 of the array should be populated in column 1 of the grid and so on. Please help in this regard.

Administrator [Syncfusion]
Replied On December 14, 2004 11:59 AM UTC

PopulateValues is a method that will efficiently populate a GridControl from some specific initial datasource like an array or a DataTable. Efficiently here means avoiding raising events that slow things down. But if you have special requirements (and it sounds like you do since you do not want to load the whole array), then you could not use the PopulateValues method. But you can always just loop through the cells you want to populate, and use an indexer based on the loop indexes to populate cells:
grid.RowCount = 10;
grid.ColCount = 8;
for(int row = 1; row <= 10; ++row)
	for(int col = 1; col <= 8; ++col)
		// change the offsets to match the columns MyArray that you want
		grid[row, col].CellValue = MyArray[row - 1, col + 1];
Now using an indexer like this will raise events, but with this many cells, the time will not be noticeable. If you were loading hundreds of thousands of cells, instead of using an indexer like grid[row, col], you would want to work directly with the dataobject. In that case, the inside of your loop would look something like: GridStyleInfo style = new GridStyleInfo(); style.CellValue = MyArray[row - 1, col + 1]; grid.Data[row, col] = style.Store; It would speed things up dozens of times for large loops.


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