I have a ListView control with CheckBoxes = true
and View = Details
on a form but I don't want the check boxes to be "checkable" by the user. I am using it for a status display of record completion. I do, however, want to use the event handler function to check the box via code (i.e. on record completion: lvMeters_ItemCheck(null, null);
).
I have disabled checking the box itself (I think, the touch screen isn't real precise on this device). However, when selecting a row (I have FullRowSelect = true
), the control often checks the checkbox and the event handler doesn't seem to be getting called.
I tried to basically undo the action in the event handler:
private void lvMeters_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (sender is ListView)
{
if (e.CurrentValue == CheckState.Checked)
lvMeters.Items[e.Index].Checked = true;
else
lvMeters.Items[e.Index].Checked = false;
}
else if (e.CurrentValue == CheckState.Checked)
lvMeters.Items[e.Index].Checked = false;
else
lvMeters.Items[e.Index].Checked = true;
}
The problem is the above handler doesn't get called on a listview select, nor does the SelectedItemChanged event handler call this event handler but it's still checking the box on select. It does get called when checking the box itself.
Ask away and I'll do my best!
So please feel free to tell me I am doing this completely wrong and should do the entire thing differently.
Sigh...I somehow managed to remove the event handler from the control when muddling with the designer. I checked at some point and it was still there but at that point I actually did have a logic/code problem.
Thanks for your answers :/