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.
Unfortunately, activation email could not send to your email. Please try again.

How to add Values to a grid control

Thread ID:





68867 Oct 4,2007 12:57 AM Oct 4,2007 03:24 AM Windows Forms 1
Tags: GridControl
Asked On October 4, 2007 12:57 AM

How to add Values to a grid control

With Regards,

Jeba S [Syncfusion]
Replied On October 4, 2007 03:24 AM

Hi Venu,

Thank you for posting query to us.

PopulateValues is a method that will efficiently populate a GridControl from some specific initial datasource like an array or a DataTable.

You can also 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.

Kindly let us know if you need any further assistance.

Best Regards,


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.

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.