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.

GridStyleInfoCustomProperties & Virtual Data

Thread ID:





18073 Aug 24,2004 02:01 AM Aug 24,2004 07:08 AM Windows Forms 7
Tags: GridControl
Raul Rosenthal
Asked On August 24, 2004 02:01 AM

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.

Administrator [Syncfusion]
Replied On August 24, 2004 02:59 AM

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.

Raul Rosenthal
Replied On August 24, 2004 03:19 AM

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?

Raul Rosenthal
Replied On August 24, 2004 03:36 AM

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.

Administrator [Syncfusion]
Replied On August 24, 2004 03:36 AM

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.

Raul Rosenthal
Replied On August 24, 2004 05:25 AM

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?

Administrator [Syncfusion]
Replied On August 24, 2004 05:41 AM

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

Raul Rosenthal
Replied On August 24, 2004 07:08 AM

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


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.