Re: Setting ListViewItem check state to indeterminate check
- From: "Claes Bergefall" <claes.bergefall@xxxxxxxxxxxxx>
- Date: Thu, 27 Oct 2005 11:17:02 +0200
Since the default listview doesn't have tri-state checkbox support
(or at least it doesn't in 1.1) you'll need to handle the state images
manually.
1. Create state images for your three different states and add
them to an imagelist
2. Add the imagelist as the StateImageList for the listview
3. Turn of checkboxes in your listview
4. Set the StateImageIndex property according to what state
the item should have.
Note that the ListViewItem.Checked, ListView.CheckedItems
and ListView.CheckedIndices properties will be useless
and you'll need to check the StateImageIndex to determine
the state of an item.
Another approach that *might* work is to enable the CheckBoxes
property and then add another stateimage to the generated
stateimagelist. Then set the stateimageindex manually when you
want the indeterminate image. This should enable the usual
checkbox handling to still work (along with the properties
mentioned above)
The ItemCheck event is of no use to you. It is used by both the
ListView and CheckedListBox, but only CheckedListBox
supports setting NewValue = Indeterminate
The Windows Forms team seems to have realized the mistake
of using the same eventarg class for both of these controls so
they added a new event (ItemChecked) to the ListView class
that doesn't have the NewValue member in it's eventargs (not
very helpful for you though).
/Claes
"Annette Miller" <nospam@xxxxxxxxxxx> wrote in message
news:eriXLso2FHA.2624@xxxxxxxxxxxxxxxxxxxxxxx
> Hi All,
>
> Wondering if anyone can help me here.
>
> I want to be able to progmatically set an item check state in a list view
> to the indeterminate (i.e. grayed in Windows Classic/Filled Square with XP
> theme) state.
>
> I realise i can do this in the Item_Checked event but I want to be able to
> set it progmatically depending on how many items are selected in another
> listview.
>
> I'm using VS2005 Beta 2 if it makes any difference.
>
> Cheers.
>
.
- Follow-Ups:
- Re: Setting ListViewItem check state to indeterminate check
- From: Annette Miller
- Re: Setting ListViewItem check state to indeterminate check
- References:
- Setting ListViewItem check state to indeterminate check
- From: Annette Miller
- Setting ListViewItem check state to indeterminate check
- Prev by Date: Re: Adding an atribute to the Columns collection for Listview
- Next by Date: dataset merge
- Previous by thread: Setting ListViewItem check state to indeterminate check
- Next by thread: Re: Setting ListViewItem check state to indeterminate check
- Index(es):
Relevant Pages
|