Back to Devexpress

RepositoryItemCheckedComboBoxEdit.Items Property

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

latest5.9 KB
Original Source

RepositoryItemCheckedComboBoxEdit.Items Property

Gets the collection of check items to be displayed in the dropdown.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Data")]
public CheckedListBoxItemCollection Items { get; }
vb
<DXCategory("Data")>
Public ReadOnly Property Items As CheckedListBoxItemCollection

Property Value

TypeDescription
CheckedListBoxItemCollection

A CheckedListBoxItemCollection collection.

|

Remarks

Items in the collection are represented by CheckedListBoxItem objects.

You can add items to the collection directly using methods provided by the CheckedListBoxItemCollection class. To add items to the collection to represent flags of a bit field, use the RepositoryItemCheckedComboBoxEdit.SetFlags method. To add items that represent elements of an enumeration to the collection, use the RepositoryItemCheckedComboBoxEdit.AddEnum method overloads.

In bound mode, the Items collection is not populated immediately when binding to a data source. To force data population, call the RepositoryItemCheckedComboBoxEdit.GetItems method.

Example

The code below populates the RepositoryItemCheckedComboBoxEdit.Items collection with five items. Each item stores a string value.

You should use the CheckedComboBoxEdit.SetEditValue method to select the “Circle” and “Ellipse” items. Then, to prevent users from deselecting it, disables the “Circle” item.

This code modifies the RepositoryItemCheckedComboBoxEdit.SeparatorChar property. This changes the edit value separator character from the default comma (“,”) to a semicolon (“;”). Ensure that the SetEditValue method uses this same separator character in its parameter.

csharp
// Add check items to the control's dropdown.
string[] itemValues = new string[] { 
    "Circle", "Rectangle", "Ellipse", 
    "Triangle", "Square" };
foreach (string value in itemValues)
    checkedComboBoxEdit1.Properties.Items.Add(value, CheckState.Unchecked, true);
// Specify the separator character.
checkedComboBoxEdit1.Properties.SeparatorChar = ';';
// Set the edit value.
checkedComboBoxEdit1.SetEditValue("Circle; Ellipse");
// Disable the Circle item.
checkedComboBoxEdit1.Properties.Items["Circle"].Enabled = false;
vb
' Add check items to the control's dropdown.
Dim itemValues As String() = New String() {"Circle", "Rectangle", _
  "Ellipse", "Triangle", "Square"}
For Each value As String In itemValues
    CheckedComboBoxEdit1.Properties.Items.Add(value, CheckState.Unchecked, True)
Next value
' Specify the separator character.
CheckedComboBoxEdit1.Properties.SeparatorChar = ";"
' Set the edit value.
CheckedComboBoxEdit1.SetEditValue("Circle; Ellipse")
' Disable the Circle item.
CheckedComboBoxEdit1.Properties.Items("Circle").Enabled = False

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

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.

xaf-how-to-display-an-enumeration-property-as-a-drop-down-box-with-check-boxes/CS/EFCore/EnumCheckBoxEF/EnumCheckBoxEF.Win/Editors/EnumPropertyEditorEx.cs#L46

csharp
//Dennis: this is required to show localized items in the editor.
foreach (CheckedListBoxItem itm in checkedItem.Items) {
    itm.Description = EnumDescriptor.GetCaption(itm.Value);

See Also

SetFlags(Type)

GetItems()

AddEnum

RepositoryItemCheckedComboBoxEdit Class

RepositoryItemCheckedComboBoxEdit Members

DevExpress.XtraEditors.Repository Namespace