winforms
winforms copied to clipboard
CheckListBox has Bugs
- .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);
}
}
}
}
`
- This is a problem with the. Net framework and does not test the. Net core
Thank you for the submission, but this repo is for .NET Core/.NET versions only. If you're welcome to update the issue if you think it is a bug in one of those. It would be great to have an animation that shows the issue.
All bugs for .NET Frameworks should be raised via VS Feedback. But I will be upfront with you - .NET Framework is done, and only critical issues will meet the servicing bar. And I can't see this bug meeting the bar.
This problem extends from. Net framework to. Net core, and still exists in various versions.
This issue is now marked as "up for grabs", and we’re looking for a community volunteer to work on this issue. If we receive no interest in 120 days, we will close the issue. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
@why5684784 I can't reproduce this. Can you please provide a more complete simple reproduction?
@Olina-Zhang I was unable to reproduce this bug, could your team give it a go. If we can't reproduce it, we can close this issue.
@elachlan This issue can reproduce in both .Net core and .Net framework for derived MyCheckListBox using following test sample. For derived MyCheckListBox, when focus on item, then move mouse to its checkBox, we need to click twice to check/uncheck. But Winforms standalone CheckedListBox, just do once.
CheckedListBoxSample.zip
@elchan if you're interested in looking into this it would be great, otherwise we're unlikely to get to it.
This submission has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 14 days.
It will be closed if no further activity occurs within 7 days of this comment.
@JeremyKuhne can you please remove the auto-close on this please?
@elachlan I presume you're going to look at it then?
That's the plan. Maybe add help wanted so we get prompted later down the line if I don't get to it.