I'm using Phillip Piper's ObjectListView
wrapper, specifically, a `TreeListView'.
My TreeListView
:
- Checkboxes: True
- CheckedAspectName: {name of bool? property in my model)
- HierarchicalCheckboxes: True
- TriStateCheckboxes: true
- View: Details
I set TriStateCheckboxes
to True because I want my TreeListView
to be able to display the indeterminate
symbol in the TreeListView’s
checkboxes. However, I don't want the user to ever be able to explicitly set a checkbox to an indeterminate
value. Rather, when a user clicks on a checkbox, I want it to toggle only between checked and unchecked. If a branch checkbox and all its children’s checkboxes are checked, and the children's checkboxes transition to a mix of checked and unchecked, I want the branch’s checkbox to show the indeterminate
symbol.
In other words, the indeterminate state is ever only to be asserted programmatically and then only on a branch when the checkboxes of the branch’s children are not solely all checked or not solely all unchecked.
Realizing that a tristate checkbox cycles: checked, indeterminate, unchecked, I tried forcing an indeterminate state to an unchecked state when the user clicks on a checked checkbox, but that didn’t work, i.e., the checkbox state in the TreeListView remains unchanged after executing my ObjTreeListViewPreview_ItemChecked code.
Note: the class ClsTreeListViewPreview derives from TreeListView
private void ObjTreeListViewPreview_ItemChecked(object sender, ItemCheckedEventArgs e)
{
ClsTreeListViewPreview ClsTreeListViewPreview = (ClsTreeListViewPreview)sender;
if (ClsTreeListViewPreview.MouseMoveHitTest.Item.CheckState == CheckState.Indeterminate)
{
ClsTreeListViewPreview.MouseMoveHitTest.Item.CheckState = CheckState.Unchecked;
}
}
Is what I want possible with a TreeListView
that has tristate
and hierarchical
checkboxes ? If so, which delegates and methods are necessary?
Aucun commentaire:
Enregistrer un commentaire