Back to Devexpress

RepositoryItemCheckedComboBoxEdit.GetCheckedItems() Method

windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitemcheckedcomboboxedit-da176fe1.md

latest6.5 KB
Original Source

RepositoryItemCheckedComboBoxEdit.GetCheckedItems() Method

Returns values of all currently checked items.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public object GetCheckedItems()
vb
Public Function GetCheckedItems As Object

Returns

TypeDescription
Object

A Object object that stores values of all currently checked items.

|

Remarks

Depending on the RepositoryItemCheckedComboBoxEdit.EditValueType, the type of the returned object differs.

csharp
#region Example 1
[Flags]
public enum MultiHue
{
Black = 1,
Red = 2,
Green = 4,
Blue = 8
};

checkedComboBoxEdit1.Properties.EditValueType = EditValueTypeCollection.CSV;
checkedComboBoxEdit1.Properties.Items.Clear();

checkedComboBoxEdit1.Properties.Items.Add(MultiHue.Black, "Flag item 1");
checkedComboBoxEdit1.Properties.Items.Add(MultiHue.Green, "Flag item 2");
checkedComboBoxEdit1.Properties.Items.Add(MultiHue.Red, "Flag item 3");

//GetCheckedItems returns the "Black, Gree, Red" string if all three items are checked

#endregion

#region Example 2

checkedComboBoxEdit1.Properties.EditValueType = EditValueTypeCollection.CSV;
checkedComboBoxEdit1.Properties.Items.Clear();

checkedComboBoxEdit1.Properties.Items.Add("One", "Item with string value");
checkedComboBoxEdit1.Properties.Items.Add(2, "Item with integer value");
checkedComboBoxEdit1.Properties.Items.Add(true, "Item with boolean value");

//GetCheckedItems returns the "One, 2, True" string if all three items are checked

#endregion
vb
'#Region "Example 1"

<Flags>
Public Enum MultiHue
Black = 1
Red = 2
Green = 4
Blue = 8
End Enum

checkedComboBoxEdit1.Properties.EditValueType = EditValueTypeCollection.CSV
checkedComboBoxEdit1.Properties.Items.Clear()

checkedComboBoxEdit1.Properties.Items.Add(MultiHue.Black, "Flag item 1")
checkedComboBoxEdit1.Properties.Items.Add(MultiHue.Green, "Flag item 2")
checkedComboBoxEdit1.Properties.Items.Add(MultiHue.Red, "Flag item 3")

'GetCheckedItems returns the "Black, Gree, Red" string if all three items are checked

'#End Region

'#Region "Example 2"

checkedComboBoxEdit1.Properties.EditValueType = EditValueTypeCollection.CSV
checkedComboBoxEdit1.Properties.Items.Clear()

checkedComboBoxEdit1.Properties.Items.Add("One", "Item with string value")
checkedComboBoxEdit1.Properties.Items.Add(2, "Item with integer value")
checkedComboBoxEdit1.Properties.Items.Add(True, "Item with boolean value")

'GetCheckedItems returns the "One, 2, True" string if all three items are checked

'#End Region
  • If the EditValueType is List , the method returns a List that contains checked items’ values.
csharp
checkedComboBoxEdit1.Properties.EditValueType = EditValueTypeCollection.List;
checkedComboBoxEdit1.Properties.Items.Clear();

checkedComboBoxEdit1.Properties.Items.Add("One", "Item with string value");
checkedComboBoxEdit1.Properties.Items.Add(2, "Item with integer value");
checkedComboBoxEdit1.Properties.Items.Add(true, "Item with boolean value");

//GetCheckedItems returns a System.Collections.Generic.List object that stores editor item values converted to strings
vb
checkedComboBoxEdit1.Properties.EditValueType = EditValueTypeCollection.List
checkedComboBoxEdit1.Properties.Items.Clear()

checkedComboBoxEdit1.Properties.Items.Add("One", "Item with string value")
checkedComboBoxEdit1.Properties.Items.Add(2, "Item with integer value")
checkedComboBoxEdit1.Properties.Items.Add(True, "Item with boolean value")

'GetCheckedItems returns a System.Collections.Generic.List object that stores editor item values converted to strings

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetCheckedItems() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-combobox-hide-specific-items/CS/MyComboBoxEdit/Form1.cs#L22

csharp
_comboBoxHideItemsHelper.Clear();
var checkedItems = indexesCheckedComboBox.Properties.GetCheckedItems() as List<object>;
foreach (var item in checkedItems) {

winforms-combobox-hide-specific-items/VB/MyComboBoxEdit/Form1.vb#L28

vb
_comboBoxHideItemsHelper.Clear()
Dim checkedItems = TryCast(indexesCheckedComboBox.Properties.GetCheckedItems(), List(Of Object))
For Each item In checkedItems

See Also

RepositoryItemCheckedComboBoxEdit Class

RepositoryItemCheckedComboBoxEdit Members

DevExpress.XtraEditors.Repository Namespace