Need to make CheckedListBox act like Choose Details in WindowsExplorer

  • Thread starter Thread starter KamiiKoneko
  • Start date Start date
K

KamiiKoneko

Specifically,
My CheckedListBox control can behave in one of two ways as far as I
can tell. #1, I set the "CheckOnClick" property, and whenever I click
a checkbox OR its label, the box is checked. OR #2 I can clear the
"CheckOnClick" property and then regardless of whether I click the
label or the checkbox, it gains focus but no action is taken until a
second click.

In Windows Explorer, when I bring up Choose Details to determine
which columns are shown in an explorer window, their CheckedListBox
behaves differently. If I click on the checkbox, focus is not given
but the checkbox checks/unchecks. If I click on the label, focus is
given but the checkbox is not checked/unchecked.

Why is there a difference, and is there a way to achieve this same
behavior in my application?

Thank you
Koneko
 
Hi,

The windows explorer control may look like a CheckedListBox, but it is in
fact a ListView. To make a ListView look like a CheckedListBox set the
following properties

ListView.HeaderStyle = ColumnHeaderStyle.None;
ListView.CheckBoxes = true;
ListView.View = View.Details;

You also need to add at least one column or any added items won't be
visible. The name of the column doesn't matter as it won't be visible
(ColumnHeaderStyle.None)
 
Back
Top