BaseCheckedListBoxControl.ItemCheck Event
Fires when the checked state of an item has been changed.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v18.1.dll
Declaration
Event Data
The ItemCheck event's data class is ItemCheckEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Index | Gets the index of the item whose state was changed. |
State | Gets the state of the item. |
Remarks
The ItemCheck event fires when the item’s CheckedListBoxItem.CheckState property is changed by programmatic modification or by user interaction. Handle this event to perform tasks when the item’s check state changes. For instance, if items are associated with options in your application, you can enable or disable options based on the items’ check state as shown in the example below.
The event parameter’s Index property represents the index of an item whose state has been changed. The item’s checked state can be identified via the State parameter.
To restrict item checking, handle the BaseCheckedListBoxControl.ItemChecking event.
Example
The following sample code changes the Label‘s font style according to the check state of the items displayed in the CheckedListBoxControl. Each item is responsible for a specific font style. Thus, you can mark the proper items to provide a desired text style.
The image below shows the result.
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
FontStyle style = FontStyle.Regular;
FontStyle[] state = {FontStyle.Bold, FontStyle.Italic, FontStyle.Strikeout,
FontStyle.Underline};
private void checkedListBoxControl1_ItemCheck(object sender, ItemCheckEventArgs e) {
if (e.State == CheckState.Checked)
style |= state[e.Index];
else
style &= ~state[e.Index];
label1.Font = new Font(label1.Font, style);
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ItemCheck event.
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.