Bug 412728 - ListBox doesn't update vscrollbar correctly when setting TopIndex
Summary: ListBox doesn't update vscrollbar correctly when setting TopIndex
Status: RESOLVED FIXED
Alias: None
Product: Mono: Class Libraries
Classification: Mono
Component: Windows.Forms (show other bugs)
Version: SVN
Hardware: i586 openSUSE 11.0
: P5 - None : Normal
Target Milestone: ---
Assignee: Jonathan Pobst
QA Contact: Mono Bugs
URL:
Whiteboard: ListBox
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-28 19:08 UTC by Mario Carrion
Modified: 2008-07-30 16:21 UTC (History)
0 users

See Also:
Found By: Beta-Customer
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
ListBox vscrollbar (3.44 KB, image/png)
2008-07-28 19:10 UTC, Mario Carrion
Details

Note You need to log in before you can comment on or make changes to this bug.
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.