There are a lot of questions :
1)-2) If you want to click once to check a box you have to set the CheckOnClick
property on the CheckedListBox
. In you case a line can be checked only once it's selected.
$clb_CC_Features.Size = New-Object System.Drawing.Size(220,110)
$clb_CC_Features.CheckOnClick = $true
$clb_CC_Features.Add_ItemCheck({})
3) The message ItemCheck append before the line is really checked so in the function you call on this even you have look if the line is going to be cheched or unchecked.
I change
$clb_CC_Features.Add_ItemCheck({ftnChecked})
#$clb_CC_Features.Add_SelectedIndexChanged({ftnUpdateFeatureSelectionCount})
#$clb_CC_Features.Add_Click({})
...
$_
represent the value of the event.
function ftnChecked ()
{
if ($_.NewValue -eq 'checked')
{
$gb_CC_Features.Text = "Features (" + $($clb_CC_Features.CheckedItems.Count + 1) + " selected)"
}
else
{
$gb_CC_Features.Text = "Features (" + $($clb_CC_Features.CheckedItems.Count -1) + " selected)"
}
}
4) You can try the following :
function ftn_CheckAllItemsInCheckList #( $checkedListBoxObject )
{
For($index =0; $index -lt $clb_CC_Features.Items.Count; $index++){ $clb_CC_Features.SetItemChecked($index, $true)}
}