CheckListBox has Bugs
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 103
Description
* .NET Core Version:
This is a problem with the. Net framework and does not test the. Net core
* Have you experienced this same bug with .NET Framework?:
Yes
**Problem description:**
This is a bug from CheckListBox.
When I derive a new CheckListBox from CheckListBox, using my derived MyCheckListBox, it will be very slow to change the itemcheckstate when the item is not selected. It will be very fast to change the itemcheckstate after selecting the item.
**Expected behavior:**
The rate at which itemcheckstate changes is independent of the itemselect state
**Minimal repro:**
every time
Code:
`
```
using System;
using System.Windows.Forms;
namespace Test.Frm.Control
{
internal class MyCheckListBox : CheckedListBox
{
public delegate void ItemBoxCheckedEventHanlder(object sender, Models.CheckListBoxItemCheckBoxEventArgs mouseEventArgs);
public event ItemBoxCheckedEventHanlder ItemBoxChecked;
private bool isUserCheck = false;
public MyCheckListBox()
{
this.DoubleBuffered = false;
}
protected override void OnItemCheck(ItemCheckEventArgs ice)
{
if (this.isUserCheck)
{
this.isUserCheck = false;
ice.NewValue = ice.CurrentValue;
}
base.OnItemCheck(ice);
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0201)///LeftMouseButtonDown
{
uint lPararm = (uint)m.LParam;
int xPoint = Convert.ToInt32(lPararm & 0xFFFF);///Convert mouse X coordinates
int yPoint = Convert.ToInt32(lPararm >> 16);///Convert mouse Y coordinates
int index = this.IndexFromPoint(xPoint, yPoint);
if (xPoint < 15)
{
Models.CheckListBoxItemCheckBoxEventArgs model = new Models.CheckListBoxItemCheckBoxEventArgs(MouseButtons.Left, xPoint, yPoint, index);
base.SetItemCheckState(index, base.GetItemCheckState(index) == CheckState.Unchecked ? CheckState.Checked : CheckState.Unchecked);
this.ItemBoxChecked?.Invoke(this, model);
}
else
{
this.isUserCheck = true;
base.SelectedIndex = index;
}
}
else
{
base.WndProc(ref m);
}
}
}
}
```
`
Contributor guide
Assessment
This issue has not been assessed yet.