Bug 412728

Summary: ListBox doesn't update vscrollbar correctly when setting TopIndex
Product: [Mono] Mono: Class Libraries Reporter: Mario Carrion <mcarrion>
Component: Windows.FormsAssignee: Jonathan Pobst <jpobst>
Status: RESOLVED FIXED QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None    
Version: SVN   
Target Milestone: ---   
Hardware: i586   
OS: openSUSE 11.0   
Whiteboard: ListBox
Found By: Beta-Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: ListBox vscrollbar

Description Mario Carrion 2008-07-28 19:08:17 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.
Comment 1 Mario Carrion 2008-07-28 19:10:16 UTC
Created attachment 230328 [details]
ListBox vscrollbar
Comment 2 Jonathan Pobst 2008-07-30 16:21:28 UTC
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.