Back to Devexpress

CheckedListBoxItemCollection.Item[Object] Property

windowsforms-devexpress-dot-xtraeditors-dot-controls-dot-checkedlistboxitemcollection-dot-item-x28-system-dot-object-x29.md

latest4.0 KB
Original Source

CheckedListBoxItemCollection.Item[Object] Property

Returns an item that has the specified value.

Namespace : DevExpress.XtraEditors.Controls

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public CheckedListBoxItem this[object value] { get; }
vb
Public ReadOnly Property Item(value As Object) As CheckedListBoxItem

Parameters

NameTypeDescription
valueObject

An object that represent’s the value of the item to be retrieved.

|

Property Value

TypeDescription
CheckedListBoxItem

A CheckedListBoxItem object whose value matches the specified object.

|

Remarks

If an editor is displaying Boolean options, each item is typically associated with a string value. So the value parameter must be a string.

If an editor is displaying a bit field (set of flags), each item’s value is a corresponding flag, and so the value parameter must specify this flag.

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

See Also

CheckedListBoxItemCollection Class

CheckedListBoxItemCollection Members

DevExpress.XtraEditors.Controls Namespace