Bug 4921 - Listbox.SelectedIndex doesn't get updated when item gets inserted before current SelectedIndex
Summary: Listbox.SelectedIndex doesn't get updated when item gets inserted before curr...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-05-07 10:54 UTC by eb1
Modified: 2012-05-24 16:30 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Unit test that demonstrates the problem and suggested fix (3.65 KB, patch)
2012-05-07 11:57 UTC, eb1
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description eb1 2012-05-07 10:54:13 UTC
I have a sorted listbox with item "B" added and selected. Then I add item "A".

listbox.Sort = true;
listbox.Items.Add("B");
listbox.SelectedIndex = 0;
listbox.Items.Add("A");
Console.WriteLine(listbox.SelectedIndex);

Expected output:
1

Actual output:
0

The SelectedIndex does not get updated.
Comment 1 eb1 2012-05-07 11:57:18 UTC
Created attachment 1821 [details]
Unit test that demonstrates the problem and suggested fix
Comment 2 eb1 2012-05-21 05:40:08 UTC
Pull request #298
Comment 3 Miguel de Icaza [MSFT] 2012-05-24 16:30:43 UTC
Tahnks!