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.

Speeing up loading data into GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

47972 Aug 16,2006 05:19 PM Aug 18,2006 04:45 PM Windows Forms 7
loading
Tags: GridControl
Julie Levy
Asked On August 16, 2006 05:19 PM

I am using the indexer approach to copy data from a dataset into a GridControl. I have special handling to do and, therefore, cannot use the PopulateValues approach.
However, it is very slow and i am trying to speed it up. I noticed on this forum a recommendation to use the following approach to speed up data copying:

GridStyleInfo style = new GridStyleInfo();
style.CellValue = MyArray[row - 1, col + 1];
grid.Data[row, col] = style.Store;

However, i am storing data in the Tag property of the cell (grid[row,col].Tag) and notice that i cannot set it anymore if i use the GridStyleInfo approach. It is always null. Before i add a hidden column, is there any way to make this faster and use the Tag property? Here''s what i was setting for the cell:

this[rowIndex, colIndex].CellValue = text;
this[rowIndex, colIndex].CellType = CELLTYPE_STATIC;
this[rowIndex, colIndex].ReadOnly = true;

Here is how i have tried to speed it up:
GridStyleInfo style = new GridStyleInfo();
style.CellValue = text;
this.Data[rowIndex, colIndex] = style.Store;
this[rowIndex, colIndex].CellType = CELLTYPE_STATIC;
this[rowIndex, colIndex].ReadOnly = true;

Thanks,
Julie

Administrator [Syncfusion]
Replied On August 16, 2006 06:36 PM

Try this.

GridStyleInfo style = new GridStyleInfo();
style.CellValue = text;
style.CellType = CELLTYPE_STATIC;
style.ReadOnly = true;
style.Tag = someObject;

this.Data[rowIndex, colIndex] = style.Store;


In your loop, do not directly index the grid at all. Doing so, will slow things down.

Julie Levy
Replied On August 17, 2006 12:56 PM

Thanks for your quick response Clay.
Two issues for me with this approach.

1. I tested setting the tag this way and still got a null when i tried to retrieve the Tag using indexing (grid[row,col].Tag). Would i have to retrieve it from the Data? from the style?

2. I actually don''t set the Tag in the loop. It''s not on every cell. Basically, it''s a row marker - i couldn''t find a Tag property on the row level so i''m storing it in one cell''s tag property per row. But, if i figure out the answer to 1., i could re-write things to set it in the loop. Or, do you have any other suggestions about how to store row-level information?

Thanks again,
Julie

Julie Levy
Replied On August 17, 2006 03:00 PM

One more thing. I have to read this tag in the PrepareViewStyleInfo event and am currently using indexing. How do i read the tag without it?

Thanks,
Julie

Julie Levy
Replied On August 17, 2006 03:09 PM

oops, ignore that last question. I see that there''s a style property in the event args. I assume this is the way to go.

Julie Levy
Replied On August 17, 2006 06:30 PM

One more update. I got the tag setting to work and am using this.Model[row, col].Tag to read it instead of this[row, col].Tag ( as well as for reading other style info).

Is this the proper way to read the info? I don''t notice very much performance improvement even though i''ve removed all direct indexing of the grid. Can you give me a list of some of the events which may still be firing so i can check them out.

Thanks,
Julie

Administrator [Syncfusion]
Replied On August 17, 2006 07:19 PM

You should see a noticeable increase in load performance using GridData over an indexer. Here is a sample illustrating this. To load 1000x100 cells with an indexer takes about 10 secs, but directly populating the GridData object takes less than a half a second.

http://www.syncfusion.com/Support/user/uploads/GridData_33cd5c1.zip

I am not sure why the Tag is not being set through the indexer. Are you handling either QueryCellInfo or SaveCellInfo? This might affect the Tag getting saved. If it works OK using th eindexer on the Model, that should not cause any other problems.

Julie Levy
Replied On August 18, 2006 04:45 PM

Thanks Clay, i finally got it going fast. It turned out to be something in my code.

Regarding setting the tag, i still had problems setting it via indexing the grid or indexing the Model if it was set after the style.Store was set on the cell ( unfortunately, i can''t set the tag value at the same time the cellvalue and other properties are set). As long as i set it beforehand, it''s okay. Afterwards, it''s always null - even right after i set it. So i''m setting it before and doing this in the data copy loop to persist it:

GridStyleInfo style = new GridStyleInfo();

style.CellValue = text;
style.CellType = CELLTYPE_STATIC;
style.ReadOnly = true;
style.Trimming = StringTrimming.EllipsisWord;
style.Tag = this.Model[rowIndex, colIndex].Tag;

this.Data[rowIndex, colIndex] = style.Store;

Thanks again for all your help,
Julie

CONFIRMATION

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.

;