Version

EditorValueSource Property

Returns or sets the source of the Value property, i.e., whether the value is obtained from the selected item or the ICheckedItemList implementation.
Syntax
'Declaration
 
Public Property EditorValueSource As EditorWithComboValueSource
public EditorWithComboValueSource EditorValueSource {get; set;}
Remarks

When the EditorValueSource property is set to 'CheckedItems', alpha-numeric keyboard entry is effectively disabled, i.e., the editor portion does not accept keystrokes. In this case the editor's value is changed by checking items, which can be done by clicking on the checkbox (or anywhere on the item depending on the value of the ItemCheckArea property), or by pressing the spacebar.

The EditorValueSource property is only applicable to the EditorWithCombo embeddable editor, and editors that derive from it.

When set to 'SelectedItem' (default), the editor's value is determined by the selected item, as was the case in previous versions. Items are selected by clicking on or navigating to an entry in the dropdown list. Doing this typically triggers a selection changed notification, which is by and large the equivalent of a change in value.

When set to 'CheckedItems', the editor's value is then determined by multiple items, namely those that are checked. Exactly what constitutes "checked" can vary between the different standalone controls that use/provide the embeddable editor. In the case of the UltraComboEditor control (which uses an EditorWithCombo embeddable editor and a ValueList), an item is "checked" if its CheckState property returns 'Checked'. A change in the value coincides with a change in the item's checked state.

The data type of the entity using the editor (for example, an UltraGrid cell) must be a type that handles arrays of simple object values, i.e., object or object[]. Additionally, the string data type is also supported. In the case where the string data type is used, the DisplayText of each item is used to build a string, and strings built in such a manner are then parsed into the individual item values (by obtaining the DataValue for each string value therein).

Example
The following code sample demonstrates how to configure the UltraComboEditor and UltraCombo controls to support "multiple item selection" using the properties of the EditorCheckedListSettings class:

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinEditors
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics

Public Class Form1
    Private _table As DataTable

    Public Sub New()

        Me.InitializeComponent()

        '   Bind the UltraComboEditor control to a data source.
        Me.ultraComboEditor1.DisplayMember = "Display"
        Me.ultraComboEditor1.ValueMember = "Value"
        Me.ultraComboEditor1.DataSource = Me.Table

        '   Bind the UltraCombo control to a data source.
        Me.ultraCombo1.DisplayMember = "Display"
        Me.ultraCombo1.ValueMember = "Value"
        Me.ultraCombo1.DataSource = Me.Table

    End Sub

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        MyBase.OnLoad(e)

        '  Set up the UltraComboEditor to show checkboxes next to the items, with middle-left alignment
        Me.ultraComboEditor1.CheckedListSettings.CheckBoxStyle = Infragistics.Win.CheckStyle.CheckBox
        Me.ultraComboEditor1.CheckedListSettings.CheckBoxAlignment = ContentAlignment.MiddleLeft

        '  Set up the UltraCombo to show its checkbox column on the left, with the checkbox middle-center aligned
        Me.ultraCombo1.CheckedListSettings.CheckStateMember = "Selected"
        Dim column As UltraGridColumn = Me.ultraCombo1.DisplayLayout.Bands(0).Columns("Selected")
        Dim checkEditor As CheckEditor = New CheckEditor()
        checkEditor.CheckAlign = ContentAlignment.MiddleCenter
        column.Editor = CheckEditor
        column.Header.VisiblePosition = 0

        '  Set up both controls to get their value from the checked items/rows
        Me.ultraComboEditor1.CheckedListSettings.EditorValueSource = EditorWithComboValueSource.CheckedItems
        Me.ultraCombo1.CheckedListSettings.EditorValueSource = EditorWithComboValueSource.CheckedItems

        '  Set up both controls so that clicking anywhere on the item changes the check state,
        '  and does not close the dropdown until the enter/escape key is pressed
        Me.ultraComboEditor1.CheckedListSettings.ItemCheckArea = ItemCheckArea.Item
        Me.ultraCombo1.CheckedListSettings.ItemCheckArea = ItemCheckArea.Item

        '  Set up both controls to use a custom list delimiter
        Me.ultraComboEditor1.CheckedListSettings.ListSeparator = " / "
        Me.ultraCombo1.CheckedListSettings.ListSeparator = " / "

        '  Handle the ValueChanged event for each control
        AddHandler Me.ultraComboEditor1.ValueChanged, AddressOf Me.OnValueChanged
        AddHandler Me.ultraCombo1.ValueChanged, AddressOf Me.OnValueChanged

    End Sub

    Private Sub OnValueChanged(ByVal sender As Object, ByVal e As EventArgs)

        '  Get the list of values from each control, and a reference
        '  to their IValueList implementation so we can get the text
        '  for each item.
        Dim values As System.Collections.IList = Nothing
        Dim valueList As IValueList = Nothing

        If sender Is Me.ultraComboEditor1 Then
            values = Me.ultraComboEditor1.Value
            valueList = Me.ultraComboEditor1.Items.ValueList

        ElseIf sender Is Me.ultraCombo1 Then
            values = Me.ultraCombo1.Value
            valueList = Me.ultraCombo1
        End If

        '  Iterate the list of values and output each one to the console
        If Not values Is Nothing Then

            Dim index As Int32 = -1

            Dim value As Object
            For Each value In values
                Dim text As String = valueList.GetText(value, index)
                Console.WriteLine(String.Format("Text = '{0}', Value = '{1}'", text, value))
            Next

        End If
    End Sub


    Private ReadOnly Property Table() As DataTable
        Get
            If Me._table Is Nothing Then
                Me._table = New DataTable()
                Me._table.Columns.Add("Value", GetType(Object))
                Me._table.Columns.Add("Display", GetType(String))
                Me._table.Columns.Add("Selected", GetType(Boolean))

                Me._table.Rows.Add(New Object() {1, "One", False})
                Me._table.Rows.Add(New Object() {2, "Two", False})
                Me._table.Rows.Add(New Object() {3, "Three", False})
                Me._table.Rows.Add(New Object() {4, "Four", False})
                Me._table.Rows.Add(New Object() {5, "Five", False})
            End If

            Return Me._table
        End Get
    End Property
End Class
using Infragistics.Win;
using Infragistics.Win.UltraWinEditors;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

public partial class Form1 : Form
{
    private DataTable table = null;

    public Form1()
    {
        this.InitializeComponent();

        //  Bind the UltraComboEditor control to a data source.
        this.ultraComboEditor1.DisplayMember = "Display";
        this.ultraComboEditor1.ValueMember = "Value";
        this.ultraComboEditor1.DataSource = this.Table;

        //  Bind the UltraCombo control to a data source.
        this.ultraCombo1.DisplayMember = "Display";
        this.ultraCombo1.ValueMember = "Value";
        this.ultraCombo1.DataSource = this.Table;
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        //  Set up the UltraComboEditor to show checkboxes next to the items, with middle-left alignment
        this.ultraComboEditor1.CheckedListSettings.CheckBoxStyle = Infragistics.Win.CheckStyle.CheckBox;
        this.ultraComboEditor1.CheckedListSettings.CheckBoxAlignment = ContentAlignment.MiddleLeft;

        //  Set up the UltraCombo to show its checkbox column on the left, with the checkbox middle-center aligned
        this.ultraCombo1.CheckedListSettings.CheckStateMember = "Selected";
        UltraGridColumn column = this.ultraCombo1.DisplayLayout.Bands[0].Columns["Selected"];
        CheckEditor checkEditor = new CheckEditor();
        checkEditor.CheckAlign = ContentAlignment.MiddleCenter;
        column.Editor = checkEditor;
        column.Header.VisiblePosition = 0;

        //  Set up both controls to get their value from the checked items/rows
        this.ultraComboEditor1.CheckedListSettings.EditorValueSource = EditorWithComboValueSource.CheckedItems;
        this.ultraCombo1.CheckedListSettings.EditorValueSource = EditorWithComboValueSource.CheckedItems;

        //  Set up both controls so that clicking anywhere on the item changes the check state,
        //  and does not close the dropdown until the enter/escape key is pressed
        this.ultraComboEditor1.CheckedListSettings.ItemCheckArea = ItemCheckArea.Item;
        this.ultraCombo1.CheckedListSettings.ItemCheckArea = ItemCheckArea.Item;

        //  Set up both controls to use a custom list delimiter
        this.ultraComboEditor1.CheckedListSettings.ListSeparator = " / ";
        this.ultraCombo1.CheckedListSettings.ListSeparator = " / ";

        //  Handle the ValueChanged event for each control
        this.ultraComboEditor1.ValueChanged += new EventHandler(this.OnValueChanged);
        this.ultraCombo1.ValueChanged += new EventHandler(this.OnValueChanged);
    }

    private void OnValueChanged(object sender, EventArgs e)
    {
        //  Get the list of values from each control, and a reference
        //  to their IValueList implementation so we can get the text
        //  for each item.
        System.Collections.IList values = null;
        IValueList valueList = null;

        if ( sender == this.ultraComboEditor1 )
        {
            values = this.ultraComboEditor1.Value as System.Collections.IList;
            valueList = this.ultraComboEditor1.Items.ValueList as IValueList;
        }
        else
        if ( sender == this.ultraCombo1 )
        {
            values = this.ultraCombo1.Value as System.Collections.IList;
            valueList = this.ultraCombo1 as IValueList;
        }

        //  Iterate the list of values and output each one to the console
        if ( values != null )
        {
            int index = -1;

            foreach( object value in values )
            {
                string text = valueList.GetText( value, ref index );
                Console.WriteLine( string.Format("Text = '{0}', Value = '{1}'", text, value) );
            }

        }
    }

    private DataTable Table
    {
        get
        {
            if ( this.table == null )
            {
                this.table = new DataTable();
                this.table.Columns.Add( "Value", typeof(object) );
                this.table.Columns.Add( "Display", typeof(string) );
                this.table.Columns.Add( "Selected", typeof(bool) );

                this.table.Rows.Add( new object[]{ 1, "One", false } );
                this.table.Rows.Add( new object[]{ 2, "Two", false } );
                this.table.Rows.Add( new object[]{ 3, "Three", false } );
                this.table.Rows.Add( new object[]{ 4, "Four", false } );
                this.table.Rows.Add( new object[]{ 5, "Five", false } );
            }

            return this.table;
        }
    }
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also