[]
Returns a compact string representation of this CellStyle.
public string BuildString()
Type | Description |
---|---|
string | A string containing the settings of all style elements defined in this CellStyle. |
This method is used to persist grid styles and can be used to define and save 'skins'.
See the BuildString(bool) and ParseString(string) methods.
The string returned contains definitions only for the style elements that are defined by this CellStyle. Elements inherited from other styles are not included. To build a string containing specific elements, use the BuildString(StyleElementFlags) method instead.
The code below creates a style with a custom font and background color and builds a string that represents the new style. Then it uses the string to initialize a second style.
// create style with custom font and back color
CellStyle cs = _flex.Styles.Add("s1");
cs.Font = new Font("Arial", 12, FontStyle.Bold);
cs.BackColor = Color.Beige;
// save style definition into a string
string styleDef = cs.BuildString();
// use string to initialize another style
CellStyle csNew = _flex.Styles.Add("s2");
csNew.ParseString(styleDef);
// compare styles
Debug.Assert(csNew.Font.Equals(cs.Font));
Debug.Assert(csNew.BackColor.Equals(cs.BackColor));
Returns a string representation of this CellStyle.
public string BuildString(StyleElementFlags elements)
Type | Name | Description |
---|---|---|
StyleElementFlags | elements | StyleElementFlags that specifies which style elements should be included in the string. |
Type | Description |
---|---|
string | A string containing the settings of the specified style elements. |
This method is used to persist grid styles and can be used to define and save 'skins'.
See the BuildString(bool) and ParseString(string) methods.
The code below shows the effect of specifying different values for the elements
parameter. It builds
one compact string containing only the elements actually defined in a style, and another including all style elements.
// build compact and a long style definition strings
string s1 = _flex.Styles.Fixed.BuildString();
string s2 = _flex.Styles.Fixed.BuildString(StyleElementFlags.All);
// show both style definitions
Console.WriteLine("{0}: {1}", s1.Length, s1);
Console.WriteLine("{0}: {1}", s2.Length, s2);