Hi people,

I can't do work fine in a combobox the properties ValueMember and DisplayMember.
In the comboBox text Mono show me the result of ToString() and is not
considering the sets of Display/ValueMember properties.

This code show the issue:

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using NUnit.Framework;

namespace Mono.Sms
{
    internal static class Program
    {
        private static void Main()
        {               
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new form());
        }
    }

    public class form : Form
    {
        private ComboBox combo = new ComboBox();
                
        public form()
        {                       
                Dictionary<string, string> dict = new 
Dictionary<string,string>();
                
                dict.Add("key1","value1");
                dict.Add("key2","value2");
        
                foreach (KeyValuePair<string, string> pair in dict)
            {
                combo.Items.Add(pair);
            }
        
                combo.ValueMember = "Value";
                combo.DisplayMember = "Key";            
        
                this.Controls.Add(combo);
                
                combo.SelectedIndex = 0;
                
                Assert.AreEqual(combo.Text, "key1");                            
        }
    }
}

-- 
Dario Quintana
http://blog.darioquintana.com.ar
_______________________________________________
Mono-winforms-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-winforms-list

Reply via email to