[Mono-winforms-list] Re: [Mono-devel-list] I can't have the listbox working

Timohy Parez tpsoftware@users.sourceforge.net
Mon, 24 Nov 2003 11:55:06 +0100


Hi,

There is nothing wrong with your code,
SelectedItem, SelectedItems[0], SelectedValue, none of them returns a
value with mono. I suggest you check bugzilla if this bug has already
been posted and if it has not, could you please submit it there?

Thnx.
Timothy P.

Op ma 24-11-2003, om 11:34 schreef Arnoux Vincent:
> OK, I didn't have a lot of success with this question, however I will
> give it a second try because I really can't figure out the reason why
> it is not working.
> Actually, the problem comes from the variable listBox.SelectedItem
> that looks to be null.
> I also did a test with listbox.SelectedItems[0]...
> Does anybody has any idea ?
> 
> Vincent
> 
> Arnoux Vincent wrote:
> > Dear list members, 
> > I tried a few things but couldn't make the following code displaying
> > my selected listbox item (i.e. the string "Selected item:" is
> > displayed, but nothing, even a blank line for the item itself). 
> > This works on .net, but doesn't want to on mono. 
> > Did I miss anything obvious ? 
> > 
> > /#define DEBUG 
> > // created on 11/11/2003 at 12:08 
> > using System; 
> > using System.Collections; 
> > using System.Windows.Forms; 
> > 
> > 
> > public class CreatedForm : System.Windows.Forms.Form 
> > { 
> >    private System.Windows.Forms.ListBox listBox; 
> >    public CreatedForm() 
> >    { 
> >        InitializeComponent(); 
> >        start(); 
> >    } 
> >      void InitializeComponent() { 
> >        this.listBox = new System.Windows.Forms.ListBox(); 
> >        this.SuspendLayout(); 
> >        // 
> >        // listBox 
> >        // 
> >        //this.listBox.Location = new System.Drawing.Point(16, 16); 
> >        this.listBox.Name = "listBox"; 
> >        //this.listBox.Size = new System.Drawing.Size(576, 199); 
> >        this.listBox.TabIndex = 0; 
> >        this.listBox.SelectedIndexChanged += new
> > System.EventHandler(this.ListBoxSelectedIndexChanged); 
> >        // 
> >        // CreatedForm 
> >        // 
> >        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 
> >        //this.ClientSize = new System.Drawing.Size(632, 446); 
> >        this.Controls.Add(this.listBox); 
> >        this.Name = "CreatedForm"; 
> >        this.ResumeLayout(false); 
> >    } 
> >      public void start() 
> >    { 
> >        listBox.BeginUpdate(); 
> >        for (int i = 0; i < 10; i++) 
> >        { 
> >            listBox.Items.Add("Item " + i); 
> >        } 
> >        listBox.EndUpdate(); 
> >    } 
> >      public static void Main() 
> >    { 
> >        CreatedForm f = new CreatedForm(); 
> >        Application.Run(f); 
> >    } 
> >      void ListBoxSelectedIndexChanged(object sender,
> > System.EventArgs e) 
> >    { 
> >        Console.WriteLine("Selected item:"); 
> >        Console.WriteLine(listBox.SelectedItem.ToString()); 
> >    } 
> > } 
> > 
> > /Best regards, 
> > Vincent/ 
> > / 
> > 
> > 
> > _______________________________________________ 
> > Mono-devel-list mailing list 
> > Mono-devel-list@lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> > 
> > 
> >