Bugzilla – Bug 412728
ListBox doesn't update vscrollbar correctly when setting TopIndex
Last modified: 2008-07-30 16:21:28 UTC
Using the following code: --- START ---- using System; using System.Drawing; using System.Windows.Forms; class ListBoxBug : Form { public ListBoxBug () { ListBox list = new ListBox (); string []range = { "A", "B", "C", "D", "E", "F", "G","H", "I", "J", "K", "L", "M" }; list.Items.AddRange (range); list.Size = new Size (100, 100); list.Location = new Point (1, 1); Button button = new Button (); button.Text = "click me"; button.Click += delegate (object sender, EventArgs args) { list.TopIndex = 10; }; button.Size = new Size (100, 25); button.Location = new Point (110, 1); Controls.Add (list); Controls.Add (button); Size = new Size (250, 200); } public static void Main (string []args) { Application.Run (new ListBoxBug ()); } } ---- END --- Clicking "click me" button will change TopIndex and the VScrollbar will be moved, however isn't updated correctly, see attached image for more information. This seems to affect ListControl-based controls, such as ListBox and CheckedListBox.
Created attachment 230328 [details] ListBox vscrollbar
Fixed in r109194, backported to 2.0 in r109279. Thanks for the report and test case! 2008-07-29 Jonathan Pobst <monkey@jpobst.com> * ListBox.cs: Don't let the user set TopIndex so high that it scrolls up far enough to show empty items. [Fixes bug #412728] 2008-07-29 Jonathan Pobst <monkey@jpobst.com> * ListBox.cs: Add test for bug #412728.