Interface IGridTableCellStyleCache
Implement this interface for elements and keep a cache with style information for individual cells if you want reduce the number of QueryCellStyleInfo calls being raised for cells of this element.
Namespace: Syncfusion.Windows.Forms.Grid.Grouping
Assembly: Syncfusion.Grid.Grouping.Windows.dll
Syntax
public interface IGridTableCellStyleCache
Remarks
Here is example code to implement this interface. It is important to keep a version value and compare the version with GridEngine.Version. This ensures that when changes are made to the engine or table that the cache is reset:
protected override void Dispose(bool disposing)
{
styles = null;
base.Dispose (disposing);
}
#region IGridTableCellStyleCache Members
ArrayList styles;
int version;
public ArrayList Styles
{
get
{
if (styles == null || this.version != Engine.Version)
{
this.version = Engine.Version;
styles = new ArrayList();
}
return styles;
}
}
public GridTableCellStyleInfo GetStyleAtColumn(int colIndex)
{
if (Styles != null && styles.Count > colIndex)
{
return styles[colIndex] as GridTableCellStyleInfo;
}
return null;
}
public void SetStyleAtColumn(int colIndex, GridTableCellStyleInfo style)
{
if (version != Engine.Version)
ResetStyles();
if (Styles.Count <= colIndex)
Styles.AddRange(new object[colIndex-Styles.Count+1]);
styles[colIndex] = style;
}
public void ResetStyles()
{
styles = null;
}
#endregion
} public class GridRecordRowWithCache : GridRecordRow, IGridTableCellAppearanceSource, IGridTableCellStyleCache
{
public GridRecordRowWithCache(RecordRowsPart parent)
: base(parent)
{
}
Methods
GetStyleAtColumn(Int32)
Returns the style for the specified column index.
Declaration
GridTableCellStyleInfo GetStyleAtColumn(int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | colIndex | The column index. |
Returns
Type | Description |
---|---|
GridTableCellStyleInfo | The style object. |
ResetStyles()
Empties the cache.
Declaration
void ResetStyles()
SetStyleAtColumn(Int32, GridTableCellStyleInfo)
Saves the style at the specified column index.
Declaration
void SetStyleAtColumn(int colIndex, GridTableCellStyleInfo style)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | colIndex | The column index. |
GridTableCellStyleInfo | style | The style object. |