Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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 for Bug 59865 on
GitHub or Developer Community if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Created attachment 25039 [details]
Minimal test case
Description of Problem:
System.Windows.Forms.ListBox will throw an ArgumentOutOfRangeException in GetItemRectangle if EnsureVisible is called when the client-height of the ListBox is smaller than the ItemHeight and there is a single item in the list. MS .net does not exhibit this behaviour.
Steps to reproduce the problem:
1. See attached minimal test case
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: GetItemRectangle index out of range.
How often does this happen?
In the EnsureVisible method of ListBox there is a code path for when index is not less than top_index, and the ListBox is not multicolumn (https://github.com/mono/mono/blob/c6d92b9983868483ec4b39b83341ffb413ad74d6/mcs/class/System.Windows.Forms/System.Windows.Forms/ListBox.cs#L2106)
For a single item, index is 0, top_index is 0. If the height is small enough that rows will also be calculated as 0 then the logic sets top_index = 1, which is out of range of the number of items in the list (1).