Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong text in ComboBox #8731

Open
gc-maximloverov opened this issue Mar 2, 2023 · 23 comments
Open

Wrong text in ComboBox #8731

gc-maximloverov opened this issue Mar 2, 2023 · 23 comments
Labels
external-OS-issue Issue caused by an external OS component such as Common Controls. help wanted Good issue for external contributors
Milestone

Comments

@gc-maximloverov
Copy link

gc-maximloverov commented Mar 2, 2023

.NET version

6.0

Did it work in .NET Framework?

No

Did it work in any of the earlier releases of .NET Core or .NET 5+?

No

Issue description

ComboBox is added to the form and DropDownStyle is set to DropDownList.
Multiple items added to ComboBox and SelectedIndex set to 0.
In runtime you need to click on the button to open the items list and very quickly move the mouse pointer to any other value in the list then 0.
ComboBox displays wrong value in text box area.
Further, if you move the mouse pointer over the list items, then the value in text box area no longer changes.

Also this problem is reproduced in DrawMode = OwnerDrawFixed.

Video:
ComboBoxIssue

Steps to reproduce

  1. Create form, add ComboBox and set DropDownStyle to DropDownList, or use sample app (then go to 3).
  2. Add 6 items to ComboBox and set SelectedIndex to 0.
  3. Run app.
  4. Click on the button to open the items list.
  5. Very quickly move the mouse pointer to any other value in the list then 0.
  6. Observe wrong value in text box area.
@gc-maximloverov gc-maximloverov added the untriaged The team needs to look at this issue in the next triage label Mar 2, 2023
@elachlan
Copy link
Contributor

elachlan commented Mar 3, 2023

@Olina-Zhang Can your team please verify this?

@Olina-Zhang
Copy link
Member

@Olina-Zhang Can your team please verify this?

Verified this issue in .Net framework 4.8.1 and .Net Core different versions, all have same result: when using mouse move the mouse pointer over the list items, the value in text box area is not changed, and when using up/down keyboard to go through the list items, the value in text box area is changed. It seems a by design issue.

.Net 8.0
Core_1

.Net framework 4.8.1
framework_1

@gc-maximloverov
Copy link
Author

Hi @Olina-Zhang
please try hovering over list item even faster like in my video. You need to have time to move the mouse while the list of elements unfolds - very quickly. It doesn't work the first time.

@denjmpr
Copy link

denjmpr commented Mar 3, 2023

@Olina-Zhang, as I can see you didn't reproduce step 5.
It cannot be "by design", because it is very strange that depending on mouse cursor moving speed user has different values inside TextBox part.

@Olina-Zhang
Copy link
Member

@gc-maximloverov How you change the value from 111 to 555 in your sample?

@gc-maximloverov
Copy link
Author

@Olina-Zhang to do this, you need to click on the button to open the drop-down list of elements with the mouse, then very quickly hover the mouse cursor over the "555" element. The main thing is the speed of hovering the mouse over the element "555", if it is not high enough, the problem will not be reproduced. This will take several tries. Restart the application if the attempt fails. In the video that I have attached, you can see how fast I move the mouse cursor.

@Olina-Zhang
Copy link
Member

@gc-maximloverov our team memebers all tried this scenario with very quickly hover the mouse cursor over other elements, no textBox value changes. It's hard to reproduce. Did you have accidental mouse-click operation when moving cursor process?
NotRepro

@denjmpr
Copy link

denjmpr commented Mar 6, 2023

@Olina-Zhang, several our team members can successfully reproduce this issue.
Also, our customers complain about this MS issue inside our controls.
All of us didn't perform mouse click acidentally or intentionally during moving cursor process.

@gc-maximloverov
Copy link
Author

gc-maximloverov commented Mar 6, 2023

@Olina-Zhang I didn't have a accidental mouse click operation. Can you try when moving the mouse cursor over the list of elements not to point to the element "111", but immediately to "555"?

@gc-maximloverov
Copy link
Author

@Olina-Zhang I have attached a project of a new test application, which, on pressing the "click me" button, reproduces the problem by simulating mouse control through the Windows API, can you run it and test it? When you click on a button, you do not need to move the mouse or press the buttons.
TestComboBox6-sim.zip

@gc-maximloverov
Copy link
Author

@Olina-Zhang added HighDpi support to test app.
TestComboBox6-sim.zip

@Olina-Zhang
Copy link
Member

@gc-maximloverov Thanks for your application, we tested it with some chance of reproducing this problem, but not 100%. In addition, when this problem is reproduced, then move mouse and click in form other place, the comboBox dropdown is collapsed, its textBox value is still "111", not "555"

@gc-maximloverov
Copy link
Author

@Olina-Zhang Thanks. Will this problem be fixed?

@Olina-Zhang
Copy link
Member

@gc-maximloverov this is an edge case, needs our engineer team to triage, @merriemcgaw what is your opinion?

@denjmpr
Copy link

denjmpr commented Mar 7, 2023

@Olina-Zhang, we have custom code in our controls which uses MeasureItem and DrawItem events.
This code allows to reproduce this issue with less quicker mouse moves.
If we'll provide you this code, will there be any chance that MS team will try to fix this issue?
In other case we can answer to our users that the core problem is inside MS ComboBox and we cannot do anything on our side.

@elachlan
Copy link
Contributor

elachlan commented Mar 8, 2023

@denjmpr If this is causing problems for you and your customers. It might be a good idea to look into the problem yourself and possibly put in a MR fixing the issue. I am sure the team would be super grateful for the effort.

@RussKie
Copy link
Member

RussKie commented Mar 8, 2023

@merriemcgaw
Copy link
Member

Given that this is potentially related to the interaction between your code and the ComboBox, there's a better than even chance that the underlying common control is the source of the problem. CommonControls are not being enhanced anymore.

@merriemcgaw merriemcgaw added this to the Help wanted milestone Mar 9, 2023
@merriemcgaw merriemcgaw added help wanted Good issue for external contributors and removed untriaged The team needs to look at this issue in the next triage labels Mar 9, 2023
@ghost
Copy link

ghost commented Mar 9, 2023

This issue is now marked as "help wanted", and we’re looking for a community volunteer to work on this issue. If we receive no interest in 180 days, we will close the issue. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@denjmpr
Copy link

denjmpr commented Apr 16, 2023

Guys, I've tried to research it a little and what I've got for now:

  1. If I'm disabling visual styles for application, the issue is not reproducible.
  2. I tried to comment out this line of code:

    And the issue is not reproducible.
    I've dig it a little and it goes to:
    m.Result = User32.CallWindowProcW(_priorWindowProcHandle, m.HWnd, (User32.WM)m.Msg, m.WParam, m.LParam);
    .

So, might it be that the actual reason is inside some OS/Native code and I cannot figure it out?
Could someone propose any other ideas or hints where I can look into?

@merriemcgaw
Copy link
Member

I'm not surprised at all to learn that the underlying OS is doing something odd between the VisualStyles ON and VisualStyles OFF modes. ProgressBar control with Visual Styles OFF can change the ProgressBar color, but Windows changed that ability in WinXP and now you can try to set a color but it won't do anything.

My assumption at this is that this would be the native code, but I have a deeper philosophical question. My expectation as a user would be for the TextBox part of the control to update once focus has settled on a new value. Moving at that speed may not even register as setting the focus. Is this a particularly visible, problematic change in the OS for your apps? If so, I would file a Feedback Ticket via the Windows Feedback Hub in the OS. It should get routed to the right team. That said, they are not taking many (if any) changes to what is considered legacy UI, so the bar for getting a fix will require a strong business justification. If you have a support contract, consider using that to engage with the Windows team as well, you may get better results that way. Unfortunately, I don't think this is something WinForms will be able to impact.

@janseris
Copy link

You could try with cpu speed reduced to e. g. 5 or 10 %. You can apply that in power settings in maximal CPU usage option. This might help "moving fast" the mouse compared to the redraw speed of the forms.

@Tanya-Solyanik Tanya-Solyanik modified the milestones: Help wanted, Future Jul 18, 2023
@elachlan
Copy link
Contributor

elachlan commented Nov 3, 2023

@denjmpr you previously mentions a simplifying of the steps to reproduce. Could you provide them here incase anyone picks this issue up again?

@elachlan elachlan added the external-OS-issue Issue caused by an external OS component such as Common Controls. label Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-OS-issue Issue caused by an external OS component such as Common Controls. help wanted Good issue for external contributors
Projects
None yet
Development

No branches or pull requests

8 participants