Members  Example 

Syncfusion.Styles Namespace : StyleInfoBase Class

StyleInfoBase Class

Provides a wrapper object for the StyleInfoStore object with type safe access to all properties stored in the style object.

Style objects provide a very user friendly way to modify data. It is very much like in Excel VBA. For example, to change the bold setting for a cell, you simply call grid[5,2].Font.Bold = True.

Object Model
StyleInfoBase ClassStyleInfoIdentityBase ClassStyleInfoStore Class
<TypeConverterAttribute("Syncfusion.Styles.StyleInfoBaseConverter, Syncfusion.Shared.Base, Version=17.1460.0.47, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89")>
Public MustInherit Class StyleInfoBase 
   Inherits Syncfusion.Design.ShouldSerializeBasedPersisterType
   Implements IStyleInfo 
Dim instance As StyleInfoBase
[TypeConverter("Syncfusion.Styles.StyleInfoBaseConverter, Syncfusion.Shared.Base, Version=17.1460.0.47, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89")]
public abstract class StyleInfoBase : Syncfusion.Design.ShouldSerializeBasedPersisterType, IStyleInfo  
The StyleInfoBase is a wrapper around the StyleInfoStore. It provides type safe accessor properties to modify data of the underlying data store and can hold temporary information about the style object that does not need to be persisted.

In Essential Grid for the example, the GridStyleInfo class holds extensive identity information about a style object such as cached base styles, row and column index, a reference to the grid model, and more. This is all the information that can be discarded when the style is no longer used (because maybe the cell is not visible anymore). Only the StyleInfoStore part needs to be kept alive.

Style objects only exist temporarily and will be created as a weak reference in a volatile data store. Once Garbage Collection kicks in smart style objects that are not referenced any more will be garbage collected. The volatile data cache can also be cleared manually.

Because Style objects know their identity they can notify their owner of changes or load base style information when the user interacts with the style object. This allows you to make changes to a style object directly, such as Cell.Font.Bold = True;

Style objects support property inheritance from parent styles, e.g. in a grid a cell can inherit properties from a parent row, column, table or a collection of names styles in a base styles map.

Style objects support subobjects. Subobjects can support inheritance (e.g. a Font.Bold can be inherited). Immutable subobjects like BrushInfo don't support inheritance of individual properties.

StyleInfoStore allows you to register any number of properties but keeps the data very memory efficient. Only properties that are actually used for a style object will be allocated for an object. The StyleObjectStore handles the storage of the object. For short integers, enums and Boolean values, the data will be stored in a BitVector32 structure to save even more memory.

Programmers can derive their own style classes from StyleInfoSubObjectBase and add type-safe (and intellisense) supported custom properties to the style class. If you write, for example, your own SpinButton class that needs individual properties, simply add a �CellSpinButtonInfo� class as subobject. If you derive CellSpinButtonInfo from StyleInfoSubObjectBase, your new object will support property inheritance from base styles.

Style objects can be written into a string (see ToString(String,IFormatProvider)) and later be recreated using the ParseString method. When writing the string you have the option to show default values (use the �d� format). Subobjects will be identified with a dot �.�, e.g. �Font.Bold�

Style object support several operations how to combine information from two styles. Style operations include: apply changes, apply initialized properties, override initialized properties, exclude properties. See the ModifyStyle method.

Style objects integrate with System.Windows.Forms.PropertyGrid. The property grid displays values that belong to a style object in bold. Values that are inherited from parent styles will be displayed as default values. The user can select several cells in a grid and the MergeStyle operation will show common settings in the property grid as bold.

Style objects support BeginUpdate, EndUpdate mechanism. This allows users to batch several operations on a style object into one transaction.

The following example shows how you can use the GridFontInfo class in Essential Grid:
standard.Font.Facename = "Helvetica";
model[1, 3].Font.Bold = true;
string faceName = model[1, 3].Font.Facename; // any cell inherits standard style
Console.WriteLIne(faceName); // will output "Helvetica"
Console.WriteLIne(model[1, 3].Font.Bold); // will output "true"
Console.WriteLIne(model[1, 3].Font.HasFaceName); // will output "False"
Inheritance Hierarchy

Syncfusion.Shared.Base: 17.1460.0.47

See Also