Reputation: 5243
I have a CheckedListBox
with 3 items. I click on first one and checked it, then I click out of the item, but I see that click has an impact on item.
There is a video
How to solve this? I would like to get click only if I click on item and not if I don't.
EDIT (special for @Kieran Devlin )
for (int i = 0; i < 3; ++i)
{
string str = "Item " + i;
checkedListBox1.Items.Add(str);
}
P.S There is nothing to add, it is very obvious question, I don't understand how I can produce min reprodusable example. It is very simple I have a checklistbox with 3 items (above) then you click on item checkbox and his state changed, then you click out of the item and his state changing again (it is a problem) user don't expect that he click out of the item and it somehow has impact on item. I don't understand what to reproduce here, sorry...
Upvotes: 0
Views: 52
Reputation: 81610
I think you have to intercept the mouse down:
public class CheckedListBoxEx : CheckedListBox
{
private const int WM_LBUTTONDOWN = 0x201;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_LBUTTONDOWN)
{
Point pt = new Point(m.LParam.ToInt32());
if (this.IndexFromPoint(pt) == -1)
{
return;
}
}
base.WndProc(ref m);
}
}
Upvotes: 1