Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

BaseCheckedListBoxControl.ReadOnly Property

Gets or sets whether or not users can check or uncheck control items. Items remain selectable even when the ReadOnly property is set to true.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

[DefaultValue(false)]
[DXCategory("Behavior")]
public bool ReadOnly { get; set; }

#Property Value

Type Default Description
Boolean false

Specifies whether users are allowed to check and uncheck items.

#Remarks

Enable the ReadOnly property to prevent users from changing selected states for all the control items. Items remain selectable, which is the main difference from the Enabled setting - if you set this property to false, the entire control deactivates.

Instead of keeping all control items in their current check states, you can handle the BaseCheckedListBoxControl.ItemChecking event and cancel specific state changes. For example, the code sample below does not allow users to select more than three items.

private void CheckedListBoxControl1_ItemChecking(object sender, ItemCheckingEventArgs e)
{
    CheckedListBoxControl control = sender as CheckedListBoxControl;
    if (control.CheckedItems.Count == 3 && e.NewValue == CheckState.Checked)
        e.Cancel = true;
}
See Also