FlexGrid for WPF | ComponentOne
C1.WPF.FlexGrid.4.6.2 Assembly / C1.WPF.FlexGrid Namespace / ColumnValueConverter Class
Members

In This Topic
    ColumnValueConverter Class
    In This Topic
    Defines a list of valid entries for a column.
    Object Model
    ColumnValueConverter Class
    Syntax
    'Declaration
     
    Public Class ColumnValueConverter 
       Implements IEditValueConverter 
    public class ColumnValueConverter : IEditValueConverter  
    Remarks

    This class deals with three common binding scenarios:

    1) Columns that can only take a few specific values. For example, you have a "Country" 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:

    // get column var c = _flexEdit.Columns["Country"]; // create and assign converter with exclusive value list c.ValueConverter = new ColumnValueConverter(GetCountryNames(), true);

    2) Columns that have a few common values, but may take other values as well. For example, you have a "Country" 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:

    // get column var c = _flexEdit.Columns["Country"]; // create and assign converter with non-exclusive value list c.ValueConverter = new ColumnValueConverter(GetCountryNames(), false);

    3) Columns that contain keys instead of actual values. For example, the 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:

    // build key-value dictionary var dct = new Dictionary<int, string>(); foreach (var country in GetCountryNames()) { dct[dct.Count] = country; } // get column var c = _flexEdit.Columns["CountryID"]; // create and assign converter with value dictionary c.ValueConverter = new ColumnValueConverter(dct); // align column to the left c.HorizontalAlignment = HorizontalAlignment.Left;
    Inheritance Hierarchy

    System.Object
       C1.WPF.FlexGrid.ColumnValueConverter

    See Also