[Mono-osx] Problem with winforms ListBox on OS X

splap james at crackle.com
Tue Jun 24 16:32:57 EDT 2008


hi all,

I'm running an issue with a Windows.Forms.ListBox control on OS X. As a
simple example of the issue, i created a winforms app with a listbox control
and a button. When the button is clicked, the DataSource of the ListBox is
modified. The code works in windows with MS .Net runtime and in windows with
Mono runtime, but fails on OS X. 

After a successful initial UI render, when you click the button the items in
the listbox disappear (Sometimes they flash onscreen for a moment before
disappearing). If I click in the section of the listbox where the items
should appear, then some of the items become visible. The listbox seems to
always know what its item collection is, but it's not displaying it
properly.

I've tried using DataSource and BindingContext in the example below. Another
piece of code (since blown away) dealt with the item list by clearing
listbox.items and adding new list of items -- same result.

Below is a little sample code that repro's the issue for me. Thanks for any
insights.

_____________________________________________________
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace testWinForms
{
	public partial class Form1 : Form
	{
		List<string> _foo;

		public Form1 ()
		{
			InitializeComponent ();

			_foo = new List<string>(new string [] { "1", "2", "3" });

			listBox1.DataSource = _foo;
		}

		private void button1_Click (object sender, EventArgs e)
		{
			_foo.Add ((_foo.Count + 1).ToString ());

			// manually clear then set datasource to force refresh

			//listBox1.DataSource = null;
			//listBox1.DataSource = _foo;
			//listBox1.Refresh ();

			// use currency manger to synch up listBox1 - works on windows
			BindingManagerBase bm = listBox1.BindingContext [_foo];
			CurrencyManager cm = (CurrencyManager) bm;
			if (cm != null) cm.Refresh ();

		}
	}
}
-- 
View this message in context: http://www.nabble.com/Problem-with-winforms-ListBox-on-OS-X-tp18097683p18097683.html
Sent from the Mono - OSX mailing list archive at Nabble.com.



More information about the Mono-osx mailing list