question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ComboBox.Text can't select items in some cases

See original GitHub issue
  • .NET Core Version: All. Also
  • Windows version: 7 and 10
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

Problem description: When ComboBox.IsEditable = False, setting the ComboBox.Text to a text that matches an item in the ComboBox should select this item. This doesn’t happen in some cases, like setting the Text property to “Test” while the ComboBox contains the items "test", "Test", "abc" or "test1", "Test", "abc" or "Test1", "Test", "abc". It seems that matching Test to test, test1, “Test1” causes some error that apports the search (which doesn’t happen in WinForms by the way). That proves this submission, is that changing the order (ComboBox contains the items "Test", "test", "abc") will make the combobox select the item Test correctly!

Minimal repro:

    <StackPanel>
        <ComboBox x:Name="ComboBox1" IsEditable="False">
            <ComboBoxItem>test</ComboBoxItem>
            <ComboBoxItem>Test</ComboBoxItem>
            <ComboBoxItem>abc</ComboBoxItem>
        </ComboBox>
        <Button Click="Button_Click">Test</Button>
    </StackPanel>
    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
        ComboBox1.Text = "Test"
    End Sub

Run the app and click the button. Nothing will be selected in the comboBox. Expected behavior is to select the Test item.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
miloushcommented, Jan 16, 2023

This is the way combobox works on winforms and how it should work in wpf not to break any ported code from winforms.

No. Winforms and WPF are fundamentally different frameworks and there should be no such expectations.

Expected behavior is to select the Test item.

The documentation (https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.combobox.text) says otherwise:

When IsEditable is false, setting this value has no effect.

Sounds like the current behavior is by design… To select an item, find the item you want and use the SelectedItem property.

0reactions
msftbot[bot]commented, Jan 31, 2023

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ComboBox.SelectedText doesn't give me the SelectedText
When the combo box loses focus, the selection point moves to the beginning of the text and any selected text becomes unselected. In...
Read more >
Combo box "Selected" not really selected until a person picks it
I have made a test and the issue is confirmed on my side. The DefaultSelectedItems property of the Combo box control is used...
Read more >
Combo box control in Power Apps - YouTube
A Combo box control allows you to search for items you will select. ... Selected Items 07:17 - Connect combo box to SharePoint...
Read more >
Power Apps Combo Box DefaultSelectedItems - YouTube
It shows the records you want in the combo box,while it will not be really selected if the user hit and select from...
Read more >
Editable Combobox issue with SelectedItem
i.e. It selects 1st element which starts with combobox text. But It doesn't shows that element it shows Text 'A'. which misleads user....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found