# C1.WPF.FlexGrid.ColumnValueConverter

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="C1_WPF_FlexGrid_ColumnValueConverter" data-uid="C1.WPF.FlexGrid.ColumnValueConverter" class="text-break">ColumnValueConverter Class
</h1>
  <div class="markdown level0 summary"><p>Defines a list of valid entries for a column.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><span class="xref">ColumnValueConverter</span></div>
  </div>
  <div class="implements">
    <h5>Implements</h5>
    <div><a class="xref" href="C1.WPF.FlexGrid.IEditValueConverter.html">IEditValueConverter</a></div>
    <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.data.ivalueconverter">IValueConverter</a></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="C1.WPF.FlexGrid.html">C1.WPF.FlexGrid</a></h6>
  <h6><strong>Assembly</strong>: C1.WPF.FlexGrid.4.6.2.dll</h6>
  <h5 id="C1_WPF_FlexGrid_ColumnValueConverter_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class ColumnValueConverter : IEditValueConverter, IValueConverter</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class ColumnValueConverter
    Implements IEditValueConverter, IValueConverter</code></pre>
  </div>
  <h5 id="C1_WPF_FlexGrid_ColumnValueConverter_remarks"><strong>Remarks</strong></h5>
  <div class="markdown level0 remarks"><pre><code>&lt;p&gt;This class deals with three common binding scenarios:&lt;/p&gt;
&lt;p&gt;1) Columns that can only take a few specific values. For example, 
</code></pre>
<p>you have a &quot;Country&quot; column of type string and a list of country names.
Users should select a country from the list, and not be allowed to enter
any countries not on the list.
The code below shows how you can handle this scenario:</p>
<pre><code>&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;// get column
var c = _flexEdit.Columns[&quot;Country&quot;];

// create and assign converter with exclusive value list
c.ValueConverter = new ColumnValueConverter(GetCountryNames(), true);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;2) Columns that have a few common values, but may take other values 
</code></pre>
<p>as well. For example, you have a &quot;Country&quot; column of type string and want to
provide a list of common country names that users can select easily. But in
this case users should also be allowed to type values that are not on the
list.
The code below shows how you can handle this scenario:</p>
<pre><code>&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;// get column
var c = _flexEdit.Columns[&quot;Country&quot;];

// create and assign converter with non-exclusive value list
c.ValueConverter = new ColumnValueConverter(GetCountryNames(), false);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;3) Columns that contain keys instead of actual values. For example, the 
</code></pre>
<p>column may contain an integer that represents a country ID, but users
should see and edit the corresponding country name instead.
The code below shows how you can handle this scenario:</p>
<pre><code>&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;// build key-value dictionary
var dct = new Dictionary&lt;int, string&gt;();
foreach (var country in GetCountryNames())
{
  dct[dct.Count] = country;
}

// get column
var c = _flexEdit.Columns[&quot;CountryID&quot;];

// create and assign converter with value dictionary
c.ValueConverter = new ColumnValueConverter(dct);

// align column to the left
c.HorizontalAlignment = HorizontalAlignment.Left;&lt;/code&gt;&lt;/pre&gt;
</code></pre>
</div>
  <h3 id="constructors">Constructors
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter__ctor" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.#ctor">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.-ctor.html#C1_WPF_FlexGrid_ColumnValueConverter__ctor">ColumnValueConverter()</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of a <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.html">ColumnValueConverter</a>.</p>
</td>
      </tr>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter__ctor_System_Collections_ICollection_System_Boolean_" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.#ctor(System.Collections.ICollection,System.Boolean)">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.-ctor.html#C1_WPF_FlexGrid_ColumnValueConverter__ctor_System_Collections_ICollection_System_Boolean_">ColumnValueConverter(ICollection, bool)</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of a <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.html">ColumnValueConverter</a> based on a simple value list.</p>
</td>
      </tr>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter__ctor_System_Collections_IDictionary_" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.#ctor(System.Collections.IDictionary)">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.-ctor.html#C1_WPF_FlexGrid_ColumnValueConverter__ctor_System_Collections_IDictionary_">ColumnValueConverter(IDictionary)</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of a <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.html">ColumnValueConverter</a> based on a dictionary.</p>
</td>
      </tr>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter__ctor_System_Collections_IEnumerable_System_String_System_String_" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.#ctor(System.Collections.IEnumerable,System.String,System.String)">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.-ctor.html#C1_WPF_FlexGrid_ColumnValueConverter__ctor_System_Collections_IEnumerable_System_String_System_String_">ColumnValueConverter(IEnumerable, string, string)</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of a <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.html">ColumnValueConverter</a> based on an object collection.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter_Exclusive" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.Exclusive">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.Exclusive.html#C1_WPF_FlexGrid_ColumnValueConverter_Exclusive">Exclusive</a>
        </td>
        <td class="markdown level1 summary"><p>Gets a value that determines whether the editor should only allow values present
in the <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.Values.html#C1_WPF_FlexGrid_ColumnValueConverter_Values">Values</a> list.</p>
</td>
      </tr>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter_Values" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.Values">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.Values.html#C1_WPF_FlexGrid_ColumnValueConverter_Values">Values</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the collection of values that should be displayed by the editor.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter_Convert_System_Object_System_Type_System_Object_System_Globalization_CultureInfo_" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.Convert(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.Convert.html#C1_WPF_FlexGrid_ColumnValueConverter_Convert_System_Object_System_Type_System_Object_System_Globalization_CultureInfo_">Convert(object, Type, object, CultureInfo)</a>
        </td>
        <td class="markdown level1 summary"><p>Converts data values into display values.</p>
</td>
      </tr>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter_ConvertBack_System_Object_System_Type_System_Object_System_Globalization_CultureInfo_" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.ConvertBack.html#C1_WPF_FlexGrid_ColumnValueConverter_ConvertBack_System_Object_System_Type_System_Object_System_Globalization_CultureInfo_">ConvertBack(object, Type, object, CultureInfo)</a>
        </td>
        <td class="markdown level1 summary"><p>Converts display values back into data values.</p>
</td>
      </tr>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter_SetSource_System_Collections_ICollection_System_Boolean_" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.SetSource(System.Collections.ICollection,System.Boolean)">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.SetSource.html#C1_WPF_FlexGrid_ColumnValueConverter_SetSource_System_Collections_ICollection_System_Boolean_">SetSource(ICollection, bool)</a>
        </td>
        <td class="markdown level1 summary"><p>Sets the converter source to a list of values to store in the cell.</p>
</td>
      </tr>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter_SetSource_System_Collections_IDictionary_" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.SetSource(System.Collections.IDictionary)">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.SetSource.html#C1_WPF_FlexGrid_ColumnValueConverter_SetSource_System_Collections_IDictionary_">SetSource(IDictionary)</a>
        </td>
        <td class="markdown level1 summary"><p>Sets the converter source to a dictionary containing keys (objects to store in the column
cells) and their corresponding display values (strings to display to the user).</p>
</td>
      </tr>
      <tr>
        <td id="C1_WPF_FlexGrid_ColumnValueConverter_SetSource_System_Collections_IEnumerable_System_String_System_String_" data-uid="C1.WPF.FlexGrid.ColumnValueConverter.SetSource(System.Collections.IEnumerable,System.String,System.String)">
          <a class="xref" href="C1.WPF.FlexGrid.ColumnValueConverter.SetSource.html#C1_WPF_FlexGrid_ColumnValueConverter_SetSource_System_Collections_IEnumerable_System_String_System_String_">SetSource(IEnumerable, string, string)</a>
        </td>
        <td class="markdown level1 summary"><p>Sets the converter source to a list of objects that contain the keys (values stored
in the column cells) and their corresponding display values.</p>
</td>
      </tr>
    </tbody>
  </table>

</div>
