# C1.Win.FlexGrid.CellStyle.BuildString

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_FlexGrid_CellStyle_BuildString_" data-uid="C1.Win.FlexGrid.CellStyle.BuildString*">BuildString Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_FlexGrid_CellStyle_BuildString_" data-uid="C1.Win.FlexGrid.CellStyle.BuildString*"></a>
<h4 id="C1_Win_FlexGrid_CellStyle_BuildString" data-uid="C1.Win.FlexGrid.CellStyle.BuildString">BuildString()</h4>
<div class="markdown level1 summary"><p>Returns a compact string representation of this <a class="xref" href="C1.Win.FlexGrid.CellStyle.html">CellStyle</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public string BuildString()</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function BuildString() As String</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><p>A string containing the settings of all style elements defined in this <b>CellStyle</b>.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_FlexGrid_CellStyle_BuildString_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method is used to persist grid styles and can be used to define and save 'skins'.</p>
<p>See the <a class="xref" href="C1.Win.FlexGrid.CellStyleCollection.BuildString.html#C1_Win_FlexGrid_CellStyleCollection_BuildString_System_Boolean_">BuildString(bool)</a> and <a class="xref" href="C1.Win.FlexGrid.CellStyleCollection.ParseString.html#C1_Win_FlexGrid_CellStyleCollection_ParseString_System_String_">ParseString(string)</a>
methods.</p>
<p>The string returned contains definitions only for the style elements that are defined by this
<a class="xref" href="C1.Win.FlexGrid.CellStyle.html">CellStyle</a>. Elements inherited from other styles are not included. To build a string containing
specific elements, use the <a class="xref" href="C1.Win.FlexGrid.CellStyle.BuildString.html#C1_Win_FlexGrid_CellStyle_BuildString_C1_Win_FlexGrid_StyleElementFlags_">BuildString(StyleElementFlags)</a> method instead.</p>
</div>
<h5 id="C1_Win_FlexGrid_CellStyle_BuildString_examples">Examples</h5>
<p>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.</p>
<pre><code class="lang-csharp">// 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));</code></pre>



<a id="C1_Win_FlexGrid_CellStyle_BuildString_" data-uid="C1.Win.FlexGrid.CellStyle.BuildString*"></a>
<h4 id="C1_Win_FlexGrid_CellStyle_BuildString_C1_Win_FlexGrid_StyleElementFlags_" data-uid="C1.Win.FlexGrid.CellStyle.BuildString(C1.Win.FlexGrid.StyleElementFlags)">BuildString(StyleElementFlags)</h4>
<div class="markdown level1 summary"><p>Returns a string representation of this <a class="xref" href="C1.Win.FlexGrid.CellStyle.html">CellStyle</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public string BuildString(StyleElementFlags elements)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function BuildString(elements As StyleElementFlags) As String</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.StyleElementFlags.html">StyleElementFlags</a></td>
      <td><span class="parametername">elements</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.StyleElementFlags.html">StyleElementFlags</a> that specifies which style elements should be included in the string.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><p>A string containing the settings of the specified style elements.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_FlexGrid_CellStyle_BuildString_C1_Win_FlexGrid_StyleElementFlags__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method is used to persist grid styles and can be used to define and save 'skins'.</p>
<p>See the <a class="xref" href="C1.Win.FlexGrid.CellStyleCollection.BuildString.html#C1_Win_FlexGrid_CellStyleCollection_BuildString_System_Boolean_">BuildString(bool)</a> and <a class="xref" href="C1.Win.FlexGrid.CellStyleCollection.ParseString.html#C1_Win_FlexGrid_CellStyleCollection_ParseString_System_String_">ParseString(string)</a>
methods.</p>
</div>
<h5 id="C1_Win_FlexGrid_CellStyle_BuildString_C1_Win_FlexGrid_StyleElementFlags__examples">Examples</h5>
<p>The code below shows the effect of specifying different values for the <code class="paramref">elements</code> parameter. It builds
one compact string containing only the elements actually defined in a style, and another including all style elements.</p>
<pre><code class="lang-csharp">// 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);</code></pre>

</div>
