# C1.Win.FlexGrid.CellStyle.MergeWith

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_FlexGrid_CellStyle_MergeWith_" data-uid="C1.Win.FlexGrid.CellStyle.MergeWith*">MergeWith Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_FlexGrid_CellStyle_MergeWith_" data-uid="C1.Win.FlexGrid.CellStyle.MergeWith*"></a>
<h4 id="C1_Win_FlexGrid_CellStyle_MergeWith_C1_Win_FlexGrid_CellStyle_" data-uid="C1.Win.FlexGrid.CellStyle.MergeWith(C1.Win.FlexGrid.CellStyle)">MergeWith(CellStyle)</h4>
<div class="markdown level1 summary"><p>Copies all elements defined in a source style to this style.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void MergeWith(CellStyle sourceStyle)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub MergeWith(sourceStyle As CellStyle)</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.CellStyle.html">CellStyle</a></td>
      <td><span class="parametername">sourceStyle</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_FlexGrid_CellStyle_MergeWith_C1_Win_FlexGrid_CellStyle__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method is used to create styles preserving existing style elements
such as <a class="xref" href="C1.Win.FlexGrid.CellStyle.DataType.html#C1_Win_FlexGrid_CellStyle_DataType">DataType</a> or <a class="xref" href="C1.Win.FlexGrid.CellStyle.Format.html#C1_Win_FlexGrid_CellStyle_Format">Format</a>.</p>
</div>
<h5 id="C1_Win_FlexGrid_CellStyle_MergeWith_C1_Win_FlexGrid_CellStyle__examples">Examples</h5>
<p>The code below changes a column so it looks like a fixed column, without
modifying the column's data type, alignment, etc.</p>
<pre><code class="lang-csharp">// create a new style
CellStyle cs = _flex.Styles.Add("newStyle");

// set data type, alignment
cs.DataType = typeof(int);
cs.TextAlign = TextAlignEnum.CenterCenter;

// copy remaining elements from "Fixed" style
cs.MergeWith(_flex.Styles.Fixed);

// assign new style to grid column
_flex.Cols[col].Style = cs;</code></pre>

</div>
