Re: Setting ListViewItem check state to indeterminate check

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.
>


.



Relevant Pages

  • Re: Listview: Wie Checked Items an den Anfang
    ... Es gibt einen Konfigurator, er legt Teile an und ordnet Teile Paketen zu. ... einem Listview alle Pakete zu sehen sind die es gibt und der Konfigurator ... markiert (Checkbox) die Pakete zu denen das Teil gehören soll. ... Der Benutzer setzt Häkchen in einer oder mehreren der Checkboxen und dann? ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Setting ListViewItem check state to indeterminate check
    ... is that no ItemCheck event is raised between 1 to 2, ... I could disable checkboxes and use stateimages and manipulate it manually ... Add the imagelist as the StateImageList for the listview ... Set the StateImageIndex property according to what state ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Lists in VB.NET CF...
    ... multiselect items on a listview - LVIs with cehckboxes seems more natural... ... > "Daniel Moth" wrote in message ... >>> I thought about using a checkbox, but I'd rather use highlighting than ... My problem is that I basically need a selection mechanism from a list, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Checking CheckBoxes in a ListView programmatically
    ... I'm trying to set CheckBox states in a ListView programmatically. ... that I need to send a Windows message to the ListView. ... The lParam value is a LVITEM structure. ...
    (comp.lang.smalltalk.dolphin)
  • Re: Listview: Wie Checked Items an den Anfang
    ... Ich verstehe nicht, was genau Du mit der Checkbox bewirken, bzw. auslösen ... Der Benutzer setzt Häkchen in einer oder mehreren der Checkboxen und dann? ... Navigationselement statt eines ListView-Controls eher das DataGrid oder ab ... Wenn der Benutzer eine Checkbox in einem ListView markiert, ...
    (microsoft.public.de.german.entwickler.dotnet.vb)