winforms icon indicating copy to clipboard operation
winforms copied to clipboard

CheckListBox has Bugs

Open why5684784 opened this issue 4 years ago • 12 comments

  • .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);
            }
        }
    }
}

`

why5684784 avatar Sep 13 '20 06:09 why5684784

  • 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.

RussKie avatar Sep 14 '20 02:09 RussKie

This problem extends from. Net framework to. Net core, and still exists in various versions.

why5684784 avatar Sep 14 '20 13:09 why5684784

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!

ghost avatar May 05 '22 04:05 ghost

@why5684784 I can't reproduce this. Can you please provide a more complete simple reproduction?

elachlan avatar Dec 12 '22 06:12 elachlan

@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 avatar Jan 18 '23 00:01 elachlan

@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 CheckBoxIssue

Olina-Zhang avatar Jan 18 '23 02:01 Olina-Zhang

@elchan if you're interested in looking into this it would be great, otherwise we're unlikely to get to it.

JeremyKuhne avatar Aug 16 '23 20:08 JeremyKuhne

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.

ghost avatar Aug 30 '23 22:08 ghost

@JeremyKuhne can you please remove the auto-close on this please?

elachlan avatar Aug 30 '23 22:08 elachlan

@elachlan I presume you're going to look at it then?

JeremyKuhne avatar Aug 30 '23 22:08 JeremyKuhne

That's the plan. Maybe add help wanted so we get prompted later down the line if I don't get to it.

elachlan avatar Aug 30 '23 22:08 elachlan