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

OnPrepareViewStyleInfo vs OnQueryCellInfo

Hi,

I am using the GC using the virtual architecture and setting some custom formatting and coloring for individual cells. Hence I had to override both event handlers. Now I have clear from other forums and my experience that you should set the values and the style of the cell in OnQueryCellInfo and the coloring such as e.Style.TextColor and e.Style.BackColor in OnPrepareViewStyleInfo.
However I feel there is this grey region of properties which I do not know where it is the correct place to be taken care of such as:
cellStyleInfo.CellValueType, cellStyleInfo.Format, gridStyleInfo.Font.Bold, gridStyleInfo.Font.
A tutorial explaining the correct use of the architecture involving these two similar events will be highly appreciated, I read in the forum how confused many other people are over this.

Thanks in advance

1 Reply

J. J.Nagarajan Syncfusion Team October 26, 2007 12:29 AM UTC

Hi Quesada ,

PrepareViewStyleInfo is generally used to modify style properties immediately before the style is used to draw the cell. So, if you have a property setting that is transient in that it dynamcailly changes and is only needed for drawing (like the backcolor depending upon the cellvalue), then PrepareViewStyleInfo is the place to do this work.

QueryCellInfo is hit anytime the grid needs a cell style for any reason. So QueryCellInfo is hit prior to PrepareViewStyleInfo, and may be hit for other reasons than preparing the style for drawing. If you use code like grid[row, col], then QueryCellInfo is hit, but PrepareViewStyleInfo may not hit. So, if you are setting a style property that may be of use to you for something other than be drawn a certain way, then you should use QueryCellInfo to set the property dynamically.

Regards,
Nagaraj

Loader.
Live Chat Icon For mobile
Up arrow icon