'宣言 Public Property EditorValueSource As EditorWithComboValueSource
public EditorWithComboValueSource EditorValueSource {get; set;}
EditorValueSource プロパティが 'CheckedItems' されている場合、英数字キーボードでの入力が無効になります。エディター部分はキーストロークを許可します。この場合、エディター値は、チェックボックスをクリック (ItemCheckArea プロパティの値に応じて項目をクリック) して項目をチェックすることにより変更されます。またはスペースバーを押します。
EditorValueSource プロパティは EditorWithCombo 埋め込みエディターおよびその派生エディターにのみ適用できます。
'SelectedItem' (デフォルト) に設定した場合、以前のバージョン同様にエディターの値は選択項目によって決定されます。項目はクリックまたはドロップダウン リストの項目へ移動して選択できます。これにより、値の変更と同様に選択変更通知をトリガーします。
'CheckedItems' に設定した場合、値はチェックされた複数の項目によって決定されます。「チェック済み」状態は、埋め込みエディターを使用または提供するスタンドアロン コントロールによって異なります。UltraComboEditor コントロール (EditorWithCombo 埋め込みエディターおよび ValueList を使用) の場合、その CheckState プロパティが 'Checked' を返したときに項目が「チェック」されます。値の変更と項目のチェック済み状態の変更は同時に起こります。
エディター (UltraGrid セルなど) を使用する入力のデータ型は、単純オブジェクト値の配列を処理する型でなければなりません。つまり、オブジェクトまたはオブジェクト[]。更に、文字列データ型がもサポートされます。文字列データ型が使用される場合、各項目の DisplayText が文字列の作成に使用され、この文字列は、(各文字列値の DataValue を取得することによって) 各項目の値に対して解析されます。
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; } } }