Need to make CheckedListBox act like Choose Details in WindowsExplorer

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
 
M

Morten Wennevik [C# MVP]

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top