Check Boxes



Only two-state check boxes are available in Better ListView Express.



To set up check boxes, set CheckBoxes property to either TwoState or ThreeState. You can disable check box on certain items by setting BetterListViewItem.AllowShowCheckBox property to

false. The following image shows three state check boxes with the last items with check box disabled:

Check boxes are supported in every view. For example, here are the check boxes enabled in Thumbnails view:

Sample Source Code

C#

this.listView.BeginUpdate();

this.listView.Items.AddRange(
    new[]
    {
        "unchecked by default",
        "checked by default",
        "indeterminate by default",
        "check box disabled"
    });

// set the first item unchecked
this.listView.Items[0].CheckState = CheckState.Unchecked;
// set the second item checked
this.listView.Items[1].CheckState = CheckState.Checked;
// set the third item in indeterminate state
this.listView.Items[2].CheckState = CheckState.Indeterminate;
// disable check box on the fourth item
this.listView.Items[3].AllowShowCheckBox = false;

// enable three-state check boxes (the same property can be used for disabling them or settings two-state ones)
this.listView.CheckBoxes = BetterListViewCheckBoxes.ThreeState;
// check boxes are supported in all views, so we can set for example the 'List' view
this.listView.View = BetterListViewView.List;

this.listView.EndUpdate();

Visual Basic

ListView.BeginUpdate()

ListView.Items.AddRange(
    New String() {
                     "unchecked by default",
                     "checked by default",
                     "indeterminate by default",
                     "check box disabled"
                 })

' set the first item unchecked
ListView.Items (0).CheckState = CheckState.Unchecked
' set the second item checked
ListView.Items (1).CheckState = CheckState.Checked
' set the third item in indeterminate state
ListView.Items (2).CheckState = CheckState.Indeterminate
' disable check box on the fourth item
ListView.Items (3).AllowShowCheckBox = False

' enable three-state check boxes (the same property can be used for disabling them or settings two-state ones)
ListView.CheckBoxes = BetterListViewCheckBoxes.ThreeState
' check boxes are supported in all views, so we can set for example the 'List' view
ListView.View = BetterListViewView.List

ListView.EndUpdate()