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
close icon

GridStyleInfoCustomProperties & Virtual Data

I have an unbound grid that uses a rather involved custom control in each cell. I have implemented all the needed code using GridStyleInfoCustomProperties and it works fine. Now I want to make the data virtual using the QueryCellInfo event, because I have to display a large number of rows. It works but it is very slow. I found that the bottleneck is in the QueryCellInfo event handler, because it must set all the properties in my GridStyleInfoCustomProperties derived class each time the event is fired, which of course happens very often. The cost is not in retrieving the data to set the properties but just in setting the properties themselves. I''d like to cache the whole style class and return it from the QueryCellInfo event handler, instead of receiving an empty style object to fill each time. Here is some code to help me explain: private void mygrid_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) { e.style.CellType = "myCellType"; MyCellStyleProperties csp = new MyCellStyleProperties( e.Style ); csp.Property1 = value1; csp.Property2 = value2; // ... csp.PropertyN = valueN; } The csp.PropertyX = valueX statements are the bottleneck. I''d like to be able to use code such as: e.Style = getMyCachedStyle( e.RowIndex, e.ColIndex ); where getMyCachedStyle would return a previously built Style object.

7 Replies

AD Administrator Syncfusion Team August 24, 2004 06:59 AM UTC

Is there a particular reason you wanted to use the custom style architecture? If not, you could encapsulate your special properties in a object class, and use that in the style.Tag property. Then, this would be easy to cache and retrieve in QueryCellInfo. You would change your custom celltype to use style.Tag to get at the properties. You aldo would want to set GridStyleInfoStore.TagProperty.IsCloneable = false; GridStyleInfoStore.TagProperty.IsDisposable = false; so the grid would be using references to your tag object and not cloning them everytime that are used. Another option might be to keep the custom style, but try using the OneTimeQueryCell info call technique discussed in this forum thread. (I have not tried this technique with custom styles, so I do not know if there is something I am overlooking that might be a problem.) http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=17783. There are likely other options to try, but I think using the Tag would be the simplest to implement and maintain.


RR Raul Rosenthal August 24, 2004 07:19 AM UTC

I thought that custom styles were the only way to display a custom control in a cell. I followed the samples that explain how to have an IE browser or a slider control in a cell. My first (naive) attempt revolved indeed around simply setting the type of the cells to "Control", but it didn''t work. Are you saying that there is another way?


RR Raul Rosenthal August 24, 2004 07:36 AM UTC

Now I have read your message more carefully. Correct me if I''m still not getting it, please. You suggest that I keep the custom cell style but that I dismiss the class I derived from GridStyleInfoCustomProperties, and instead copy the values of the properties from an object attached to Style.Tag. But, where should I do the copy? Right now, the GridStyleInfoCustomProperties derived class manages a single instance of my custom control and populates its properties as needed. Sorry, but I am lost.


AD Administrator Syncfusion Team August 24, 2004 07:36 AM UTC

You probably still need a custom cell control, but there are several ways you can use the style object to maintain information your custom cell control requires. You communicate with your custom cell control through the style object. Your renderer.OnInitialize method is where you take the style and somehow initialize your control from its properties. Your renderer.Draw method takes the style and uses it to decide how/what to draw. Your renderer.OnSaveChanges takes the state of the control and moves it back into the style so the style will reflect any changes the control made to its state. Adding custom properties to the style is just one way to cache information in the style that is needed by your cell control. But there are others as well, such as the Tag object. You can put anything there you want. Then in your renderer overrides, you can retrieve it from the style.Tag to be used how ever you want. For examples, the Grid\Samples\In Depth\DerivedCellControlTutorial sample uses a Tag to hold the hyperlink used in teh LinkLabel cell, and in the Samples\In Depth\ExcelSelectionMarker, the Tag is used to hold a bitmap required by a custom cell control there.


RR Raul Rosenthal August 24, 2004 09:25 AM UTC

Thank you. I''m going to try this method. Meanwhile, I downloaded the OneTimeOnlyQueryCellInfo sample and are studying it. Alas, it doesn''t compile because the project misses the IGridVolatileData interface. Where is this interface defined?


AD Administrator Syncfusion Team August 24, 2004 09:41 AM UTC

It is defined in this file. Syncfusion\Essential Suite\2.1.0.9\Grid\Src\Base\Model\GridVolatileData.cs(33): public interface IGridVolatileData : IGridData I think it was in 2.0.5.1, but may not have been in earlier versions.


RR Raul Rosenthal August 24, 2004 11:08 AM UTC

Argh! I''m still using v1.6.1.8, because I have been experiencing some problems with licensing with v2.x (up to 2.0.5.43). But now that I have scratched the GridStyleInfoCustomProperties class as you suggested, my application works just fine. Thank you.

Loader.
Live Chat Icon For mobile
Up arrow icon