Skip to main content

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.v23.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