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

QueryCellInfo

Hi It is unclear to me how querrycellinfo works. It looks like it called for each cell on the visible area even if only one changed.

13 Replies

AD Administrator Syncfusion Team February 16, 2005 10:12 AM UTC

QueryCellInfo is call whenever the grid needs a cell style for any reason. In 3.0.1.0 (or 2.1.0.9), it should not be called for every cell if only one cell is changed from code. But if you move your mouse over the grid, it will be called as teh mouse moves (the grid needs the cell style ot do hittesting). Or, if you callgrid.Refresh or grid.Invalidate then QueryCellInfo would be hit more. Can you reproduce the problem you are having in one of our samples?


AD Administrator Syncfusion Team February 16, 2005 11:41 AM UTC

I tried the GridPopulation Sample: -It looks like the gridControl1.Model.PopulateValues(); gives much better performance. But where is the style populated ? Why then using the QueryCellInfo ? -When we move a winform other the grid, the repainting of this windows seems to be call too many times giving a bad user experience. Are you aware of that and is there a solution ? Thanks


AD Administrator Syncfusion Team February 16, 2005 12:36 PM UTC

Is it possible to remove the fire of Querycellinfo when the mouse moves?


AD Administrator Syncfusion Team February 16, 2005 12:48 PM UTC

The QueryCellInfo architecture to provide the style information dynamically is by design. As you say, even if you explicitly populate a GridControl with PopulateValues, this event continues to be raised. If you use QuerycellInfo, then you need to optimize the code that provides the style information as much as possible. This might include caching it in some local data storage for quick look up. The PopulateValues method loops through your data source and moves style information into the gridControl1.Data using calls to grid.SetCellInfo. If you want to avoid the QueryCellInfo event, take a look at the Syncfusion\Essential Suite\3.0.1.0\Windows\Grid.Windows\Samples\Performance\OneTimeOnlyQueryCellInfo sample.


AD Administrator Syncfusion Team February 16, 2005 01:57 PM UTC

It''s very hard to understand... Can i call someone at the support and get a one time anwser ? The OnetimeQuerryCellInfo uses another cache... but it does raises the querycellInfo. I have a structure that holds the style in the querycellinfo: if(e.RowIndex>=RowHeaderCount && e.ColIndex>0) { e.Style.ModifyStyle (_columns[gridColIndex.ColIndex].ColumnAttributes.ColRenderer.Style,Syncfusion.Styles.StyleModifyType.ApplyNew ); e.Style.CellValue=gc.CellValue; e.Handled = true; } So what should i do : use the querrycellinfo or not ? It''s not clear if i need it at all ... Thanks


AD Administrator Syncfusion Team February 16, 2005 02:17 PM UTC

Clay Actually it looks like all the grid is refrehed every time when i call _grid.RefreshRange(...); Because when i filter in the querrycellinfo to display only those cells that have changed i get the cells that did not changed to blank. So what are the common reason for the querrycellinfo to display the whole screen ?


AD Administrator Syncfusion Team February 16, 2005 03:55 PM UTC

What version are you using? Is it 3.0.1.0? QueryCellInfo should only be hit for the cells referenced in RefreshRange. Here is a little sample project that illustrates this happening. http://www.syncfusion.com/forums/Uploads/GC_QueryCellInfo021605.zip If your style is only changed column by column, if you explicitly set grid.ColCount = something, then you can just set the column style properties in the grid.ColStyles collection. The grid will handle things from there for you. If you do not want to explicitly set grid.ColCount (as this does allocate some column objects), then you can provide the column style in the QueryCellInfo event itself. It e.RowIndex == -1 and e.ColIndex > 0, then set e.Style to be your column style for the column specified by e.ColIndex.


AD Administrator Syncfusion Team February 16, 2005 04:04 PM UTC

*Thanks for the simple it work well, and i understand. *I use the latest version of the grid 3.1 *For any reason in my code every time i call RefreshRange between a beginupdate(Invalidate)/Endupdate(true) it refreshed the whole grid.


AD Administrator Syncfusion Team February 16, 2005 04:54 PM UTC

If you do BeginUpdate, EndUpdate with those options set, the grid does not track individual cells to be invalidated. Instead, it invalidates the smallest rectangle that holds all the cells that need to be drawn. I suspect this is what you are seeing. In this situation, you might just try removing the BeginUpdate/EndUpdate to see if you get better performance without it.


AD Administrator Syncfusion Team February 17, 2005 07:56 AM UTC

I do see better performance indeed. -Is there a way to cancel the firing of querycellinfo each time the mouse moves over the grid ? -Also relating to your previous answer, how to improve performance could i tell the grid to rely on my external "style" store ? -When highlighting the row, the current cell is different. since my grid is editonly how could i prevent this effect ? Thanks again for the GREATEST support ever !


AD Administrator Syncfusion Team February 17, 2005 09:41 AM UTC

>-Is there a way to cancel the firing of querycellinfo each time the mouse moves over the grid ? Only if you use something like the OneTimeOnlyQueryCellInfo. >-Also relating to your previous answer, how to improve performance could i tell the grid to rely on my external "style" store ? You could use GridControl.Data as your ''external style store''. Theis would simply mean that you are not using a virtual grid, but instead are letting the grid store the information you need to store. >-When highlighting the row, the current cell is different. since my grid is editonly how could i prevent this effect ? You can handle the CellDrawn event and color the cell there by overdrawing it with the selection color.
private void grid_CellDrawn(object sender, GridDrawCellEventArgs e)
{
 	GridCurrentCell cc = this.grid.CurrentCell;
	 if(e.ColIndex == cc.ColIndex && e.RowIndex == cc.RowIndex)
	 {
 		 using(SolidBrush br = new SolidBrush(this.grid.AlphaBlendSelectionColor))
  		{
   			e.Graphics.FillRectangle(br, e.Bounds);
 		 }
	}
}


AD Administrator Syncfusion Team February 17, 2005 11:30 AM UTC

The one timequerycellinfo does not seem appropriate for frequent updates and using the nonvolatile datacache decreased the perf in my situation... Are both related ? Do you have any sample for the GridControl.data ? Actually since i have an object that encapsulates the GridStyleinfo, i can provide it whenenver needed so how this grid data store is usefull ?


AD Administrator Syncfusion Team February 17, 2005 04:14 PM UTC

>>Do you have any sample for the GridControl.data ? You use the GridControl.Data object when you populate the grid directly using either an indexer on the grid or grid.SetCellInfo or grid.PopulateValues. It is teh data cache used by the grid when you want the grid to store things for you. So, all the GridControl samples that are not virtual grids use this datastore. >Actually since i have an object that encapsulates the GridStyleInfo, i can provide it whenenver needed so how this grid data store is usefull ? The GridControl.Data object which holds (essentially) GridStyleInfo objects is likely more efficient that your objects that encapsulate the GridStyleInfo objects. If you want to use your encapsulated gridStyleInfo objects, then you would want to use QueryCellInfo to provide them on demand if they are dynamic in nature(constantly changing). If they are more or less static, you could try using QueryCellInfo or you could move them into the GridControl.Data object so the grid can access then through that object (which may be more efficient). The tradeoff is teh time it requires to populate the GridControl.Data object from your encapsulated style objects. Another possiblity is not to use your encapsulated style objects, but instead just set the apprpriate property settings in GridControl.Data and always use the object. (It is serializable).

Loader.
Live Chat Icon For mobile
Up arrow icon